Android中的线性布局(LinearLayout)
16lz
2021-01-24
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
解释上面代码的意思:
<LinearLayout>标签:定义了整个程序显示的布局。
在LinearLayout布局中,android:orientation用于定义布局中子元素的排列方式,布局包含两种排列方式:vertical(垂直排列)和horizontal(水平排列)。
android:layout_width 定义了元素布局的宽度,可以通过三种方式来指定宽度。
1)fill_parent:宽度和父元素相同;
2)wrap_content:宽度随组件本身的内容调整;
3):通过指定px值来设置宽度。
android:layout_height 定义了元素布局的高度,可以通过三种方式来指定高度。
1)fill_parent:宽度和父元素相同;
2)wrap_content:宽度随组件本身的内容调整;
3):通过指定px值来设置宽度。
更多相关文章
- Android(安卓)简单计算器源码....
- Android(安卓)线性布局(LinearLayout)相关官方文档 - 布局参数部分
- Android加速启动Activity
- Android(安卓)不同View ID相同
- TextView的常用属性
- android 实现FlowLayout 流线布局(自定义ViewGroup)
- TextView属性大全!技术干货
- 第八章 Android(安卓)开发常见的UI布局
- android——Include进来的GridView无法显示