线性布局,控件成直线方式排列,要么水平排列,要么垂直排列。
对着layout文件夹右键,然后选择新建android xml file,选择资源类型选择 layout --> 根节点选择 LinearLyout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:text="第一个TextView"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FF00"
android:text="第二个TextView">
android:orientation设置方向(垂直(vertical)和水平(horizontal)),如果设置布局方向是水平的话,那么控件的width就不要设置为相对父控件,不然其他控件就会被挤出屏幕外面去了。
效果: