Android之LinearLayout学习
来源:互联网 发布:淘宝店过户 编辑:程序博客网 时间:2024/05/17 04:46
LinearLayout(线性布局)
1.将控件排列为一行或一列,这取决于它的方向orientation 属性设置。线性布局分为水平线性和垂直线性二者的属性分别为:
android:orientation= " horizontal " 水平线性布局
android:orientation= "vertical" 竖直线性布局
2.android:gravity作用是控制布局文件中控件的对齐方式。当对没有子控件的控件设置时,此时指的是控件内容相对控件的对齐方式。例子如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:gravity="right|top" //设置为右上方,不会改变控件本身位置
android:layout_width="150dp"
android:layout_height="150dp"
android:text="确定"
android:textSize="30sp"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消" />
</LinearLayout>
效果图
当对有子控件的父控件设置时,此时指的是子控件相对于父控件的对齐方式。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right" //设置下面的子控件右对齐父控件
android:orientation="horizontal" >
<Button
android:gravity="right|top"//设置为右上方,不会改变控件本身位置
android:layout_width="100dp"
android:layout_height="100dp"
android:text="确定"
android:textSize="30sp"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消" />
</LinearLayout>
效果图3.android:layout_weight作用是设定该控件所占整个界面布局的比重。
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff1493" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#b0e0e6" />
注释:总的weight是2,两个各占一半。
- Android之LinearLayout学习
- android学习之LinearLayout
- Android学习第一天之LinearLayout浅析
- Android学习笔记十三之LinearLayout布局
- Android学习笔记十三之LinearLayout布局
- android:linearlayout 学习
- Android之LinearLayout、AbsoluteLayout
- android布局之LinearLayout
- android之布局LinearLayout
- Android 布局 之 LinearLayout
- android 之LinearLayout布局
- android之LinearLayout
- Android之LinearLayout布局
- Android布局之LinearLayout
- android 之LinearLayout布局
- android之LinearLayout
- Android布局之LinearLayout
- android之LinearLayout
- 加密术相关历史典故
- android GridView视图的案例
- jfinal中model转map的方法实现
- 绿萝算法下网站站长如何建设外链
- 线程状态
- Android之LinearLayout学习
- 使用命令行模拟Eclipse中Android Project的编译流程(从源代码编译出最后的apk)
- HOJ 1191 (next_permutation()的应用)
- 2014.3.29阿里实习笔试题
- Android中完美解决CheckedTextView选择乱跳问题
- maven springMVC+Mybatis
- dispatch_semaphore_create信号
- 数组指针(int *)(&a+1)
- dedecms V5.7笔记:判断空值或含有某个值的写法(例如是否推荐文章,是否图片等)及field:picname function='thumb(@me最大比例缩图的显示判断