1:LinearLayout
来源:互联网 发布:mac book pro 201515.4 编辑:程序博客网 时间:2024/06/03 19:40
直接上代码:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.yunlibeauty.test.MainActivity" android:orientation="vertical"
android:id="@+id/base_layout"><LinearLayout
android:id="@+id/layout1"
android:layout_width="match_parent" android:layout_height="0dp"
android:background="@color/colorAccent"
android:layout_weight="1"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/layout2"
android:layout_width="match_parent" android:layout_height="0dp"
android:background="@color/colorPrimaryDark"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/layout2_1"
android:layout_width="0dp"
android:layout_height="match_parent" android:layout_weight="1"
android:background="@color/colorC"
tools:ignore="Suspicious0dp" />
<LinearLayout
android:id="@+id/layout2_2"
android:layout_width="0dp"
android:layout_height="match_parent" android:layout_weight="1"
android:background="@color/colorB"
tools:ignore="Suspicious0dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/colorPrimary" >
</LinearLayout>
</LinearLayout>
我这里首先把屏幕垂直分成了三分, layout1、layout2、layout3. 在layout2里我又水平分成两份 layout2_1及layout2_2
结合代码LinearLayout常用属性:
1:id作为layout的标识
2:orientation布局的方向,是垂直布局还是线性布局,比如最外层id为base_layout的我设为了垂直,先垂直分成的三分。而在layout2里我设置了水平布局,所以水平分成了两份
3:layout_width、layout_height,指定的是布局的宽高,一般不直接去写数字,会设为fill_parent\match_parent(这里我用了或,因为他们两是一样的,Android2.2以后是一样的,2.2之前没有match_parent)、wrap_content组件的实际大小
4:layout_weight 占的权重,比如我都设为了1,如果我将id为layout1的设为2,那layout1将会占用屏幕的一半。
5:backgroud:背景,可以设置为颜色或者图片
阅读全文
0 0
- 1:LinearLayout
- LinearLayout
- LinearLayout
- Linearlayout
- LinearLayout
- LinearLayout
- LinearLayout
- Linearlayout
- LinearLayout
- LinearLayout
- LinearLayout
- LinearLayout
- LinearLayout
- LinearLayout
- LinearLayout
- LinearLayout
- android Layout 之LinearLayout(1)
- android布局(1)- LinearLayout
- 利用JAVA实现判断某一年是否为闰年
- 如何将EXCEL表导入MYSQL
- YOLO中参数和函数说明
- vuejs使用vux出错Module build failed: Error: Cannot find module 'less'
- cmd乱码
- 1:LinearLayout
- 吴恩达Coursera深度学习课程 DeepLearning.ai 提炼笔记(4-3)-- 目标检测
- Overload与Override的区别
- 一个简单明了的OKhttp封装类
- warning: unrecognized command line option "-Wno-extern-c-compat" [enabled by default]
- MySQL循环
- 超链接当做书签来使用
- 用命名管道实现进程间的通信-----简单聊天室的建立
- UVA455