Here you will get Android LinearLayout example.
在这里,您将获得Android LinearLayout示例。
LinearLayout is a very basic and most commonly used layout in Android. It is used to align or arrange its children either horizontally or vertically. The horizontal or vertical orientation can be specified using android:orientation attribute. By default the orientation is horizontal.
LinearLayout是Android中非常基本且最常用的布局 。 它用于水平或垂直对齐或排列其子级。 可以使用android:orientation属性指定水平或垂直方向。 默认情况下,方向是水平的。
Below I have shared an example for both orientations. I have used three buttons and arranged them in horizontal and vertical manner.
下面,我分享了两个方向的示例。 我使用了三个按钮,并以水平和垂直方式排列它们。
Android LinearLayout示例 (Android LinearLayout Example)
水平方向 (Horizontal Orientation)
<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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apple"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Banana"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Orange"/>
</LinearLayout>

垂直方向 (Vertical Orientation)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apple"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Banana"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Orange"/>
</LinearLayout>

The code is self-explanatory, still if you are facing any difficulty to understand then you can ask by commenting below.
该代码是不言自明的,但是如果您仍然难以理解,那么可以在下面的注释中提问。
翻译自: https://www.thecrazyprogrammer.com/2015/12/android-linearlayout-example.html