[android]布局(容器)简介和使用方法

布局(控件)---用来存放控件,并控制他们的位置排列


inearLayout---线性布局--控件安书序排成一行或者一列

属性:

         android:layout_width=""---布局宽

         android:layout_height=::---布局高

         android:orientation=""---设定布局中的控件的排列方式---水平或者垂直


RelativeLayout---相对布局---控件依靠与父容器/同一容器中的其他控件的相对位置显示排列

属性:

         android:layout_width=""---布局宽

         android:layout_height=""---布局高

         android:orientation=""---本人认为没有意义


TableLayout---表格布局---通过TableRow来定义一行---其中的元素通常不需要指定宽、高

属性:

        android:layout_width=""---布局宽

        android:layout_height=""---布局高

        android:stretchColums=""---要拉伸的列


FrameLayout---框架布局---默认出现在左上角

属性:

        <merge xmlns:android="http://schemas.android.com/apk/res/android">

        </merge>

        如果你的布局xml文件是以FrameLayout为布局,可以省略,直接写成上面的形式,优化布局,系统默认底层就是FrameLayout   

     

把布局加载到Activity中

LayoutInflater inflater=LayoutInflater.from(Context context);

inflater.inflate(int resource,ViewGroup root);-----参数  R.layout.main   null


把控件加载到Activity中

View  findViewById(int id);





        

你可能感兴趣的:([android]布局(容器)简介和使用方法)