android的布局方式有几个,线性布局,绝对布局,表格布局,相对布局,针布局(可以做动画效果 一针就是一个元素,每秒x针就是说屏幕上的元素一秒变化的数量)常用的是相对布局;RelativeLayout;
下面就简单使用一下相对布局,同时来复习android的工程的各个文件的作用;
在建好的一个工程中,打开main.xml文件
<?xml version="1.0" encoding="utf-8"?>//这里修改成了RelativeLayout 是相对布局了;<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    >/*这是第一个元素,文字内容是android:text="@string/hello"引用的string.xml中的hello这个属性的值;布局高度和宽度都是随着内容来设定的。这里有个新的标签属性,android:id这个属性是给这个标签起一个唯一的名字,起名字的方法是="@+id/customput这个值的意思是在R.java文件中的id的静态变量中添加一个名字是customput的常量;当你写好这个属性和值保持后 你去看你的R.java文件 你会发现自动产生了public static final class layout {        public static final int main=0x7f030000;    }这些代码;这样你就知道怎么用了把*/<TextView      android:text="@string/hello"    android:id="@+id/customput"    android:layout_height="wrap_content" android:layout_width="wrap_content"/>/*这是另一个元素,这个元素和上面的一样 是个文本框,他的位置是在上一个元素的右边 你问我怎么知道的?是这句话告诉我的android:layout_toRightOf="@id/customput"他用了上个元素的唯一的名字*/    <TextView      android:layout_toRightOf="@id/customput"    android:text="@string/submitName"    android:layout_height="wrap_content" android:layout_width="wrap_content"/></RelativeLayout>

string.xml
<?xml version="1.0" encoding="utf-8"?><resources>    <string name="hello">Hello World, HelloWorldActivity!</string>    <string name="app_name">第一个应用</string>    <string name="submitName">button</string></resources>

R.java
/* AUTO-GENERATED FILE.  DO NOT MODIFY. * * This class was automatically generated by the * aapt tool from the resource data it found.  It * should not be modified by hand. */package com.android.activity;public final class R {    public static final class attr {    }    public static final class drawable {        public static final int icon=0x7f020000;    }    public static final class id {        public static final int customput=0x7f050000;    }    public static final class layout {        public static final int main=0x7f030000;    }    public static final class string {        public static final int app_name=0x7f040001;        public static final int hello=0x7f040000;        public static final int submitName=0x7f040002;    }}

这样完成后的效果是这样的

可以看到button在文字的右边

更多相关文章

  1. React Native Android(安卓)ScrollView 去除阴影效果
  2. Android矢量图(二)--VectorDrawable所有属性全解析
  3. TextView支持的XML属性及相关方法
  4. Android使用LayerDrawable资源
  5. Android清单文件详解(六) ---- 节点的属性
  6. Android(安卓)Material Design之在RecyclerView中嵌套CardView实
  7. 共享全局数据 android
  8. android中TextView实现单行跑马灯
  9. android该系统的应用API选择演示版本

随机推荐

  1. Android(安卓)切换主题 (二)
  2. Android高手进阶教程(十六)---Android中I
  3. Android(安卓)资源文件使用方法详解
  4. android开发的3种方式
  5. android事件拦截处理机制详解
  6. Android(安卓)数据存储五种方式使用与总
  7. Android(安卓)采用HttpClient提交数据到
  8. Android利用已有控件实现自定义控件
  9. Android开发规范最新详尽版下载
  10. Android(安卓)Intent详解