1.**
线性布局位置
**:在布局文件Linear Layout中android:orientation属性。其中 vertical代表控件以垂直方向排列,horizontal代表控件以水平方向排列
2.这里我们写了四个按钮控件分别展示两种不同的排列。
效果如图:
horizontal
源代码如下:
在这里插入代码片
```<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
/>
<Button
android:id="@+id/button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"/>
<Button
android:id="@+id/button_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3"/>
<Button
android:id="@+id/button_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 4"/>
</LinearLayout>
## vertical
将第一次代码horizontal改为vertical即可。