EasyClick原生UI连载目录
EasyClick原生UI连载总纲
讲师:Mr-老鬼,QQ:1156346325
EasyClick 原生UI教程电梯直达:EasyClick 原生UI教程总纲
EasyClick 原生UI之布局
- LinearLayout 线性布局
- FrameLayout 帧布局
- RelativeLayout 绝对布局
- ScrollView 滚动框布局
- RadioGroup 单选布局
- include 引用布局
LinearLayout 线性布局
说明:
LinearLayout,中文意思就是线性布局, 在实际开发中比较常用的布局,它主要以水平和垂直的方式来显示界面中的控件。 在线性布局中,线性布局管理器允许为每一个子视图指定一个 weight 属性,以控制每一个子视图在空间内的大小。 而线性布局中的 orientation 属性则是用于控制控件的排列方向。
android:orientation="vertical"属性将其指定为垂直线性排列;
android:orientation="horizontal"属性将其指定为水平线性排列;
<!--这是线性布局-->
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="20dp">
<!--这里面是控件-->
</LinearLayout>
FrameLayout 帧布局
说明:
FrameLayout,帧布局是最为简单的一种布局,该布局为每个加入其中的控件创建一个空白区域,称为一帧,每个控件占据一帧。采用帧布局时,所有控件都默认显示在屏幕左上角,并按照先后放入的顺序重叠摆放,先放入的将会在最底层,后放入的控件显示在最顶层。帧布局使用于图层设计。
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<!--这里面是控件-->
</FrameLayout>
RelativeLayout 相对布局
说明
相对布局是通过相对定位的方式制定控件位置,即以其他的控件或父容器为参照物,摆放控件位置。在设计相对布局时要遵循控件之间的依赖关系,后放入的控件的位置要依赖于先放入的控件。
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<!--这里面是控件-->
</RelativeLayout>
ScrollView 滚动框布局
说明:
可以滚动的布局控件,子元素只能有一个
<ScrollView android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 这里面是控件 只能有一个子元素,子元素里面可以任意个 -->
<LinearLayout android:layout_height="match_parent"
android:orientation="vertical"
android:layout_width="match_parent">
<!-- 这里面可以是任意个布局和控件 -->
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="sctest"
/>
</LinearLayout>
</ScrollView>
RadioGroup 单选布局
说明:
RadioGroup可以提供几个选项供用户选择,但只能选择其中的一个。
<RadioGroup android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="100dp"
android:orientation="horizontal">
<!--这里面是控件-->
<RadioButton android:layout_height="80dp"
android:layout_width="50dp"
android:text="r1"
android:tag="r1"
android:gravity="center"/>
<RadioButton android:layout_height="80dp"
android:layout_width="50dp"
android:text="r2"
android:gravity="center"
android:tag="r2"/>
</RadioGroup>
include 引用布局
注意
文中没有提到的属性请参考
公有属性: EasyClick 原生UI连载 三
我是Mr-老鬼、QQ1156346325 。交流QQ群:620028786,647082990
---------------------------------------版权声明------------------------------------------------------
版权所有~Mr-老鬼 ~转载请注明原文地址。
免责声明:本文所有的教程仅限交流学习使用不得用于违法用途,造成的法律后果本人不承担责任。