Detailed explanation of Android LinearLayout linear layout
In order to better manage the components in the user interface of Android applications, Android provides a layout manager. By using layout manager, Android application graphical user interface has good platform independence. It is recommended to use layout manager to manage the distribution and size of components, rather than directly setting the location and size of components. You can use layout manager to nest layout managers, which can also be used as a UI component.
LinearLayout can control the horizontal or vertical arrangement of components. The content will not wrap, and the part beyond the screen will not be displayed.
XML: android:orientation="horizontal"
Horizontal: Horizontal
Vertical: vertical arrangement
JAVA :linearLayout.setOrientation(LinearLayout.VERTICAL);
Linearlayout.horizontal
Linearlayout.vertical vertical
XML: android:gravity="center"
JAVA :linearLayout.setGravity(Gravity.CENTER);
Datum line:
Open the English exercise book, the red line is the benchmark
XML: android:baselineAligned="false"
JAVA: linearLayout.setBaselineAligned(true);
代码:true
效果:
@H_ 876_ 301@
There are many textviews in a LinearLayout. Each textview has its own baseline, so the LinearLayout may also be a child element of another LinearLayout. As a child element, baselinealignedchildindex determines its baseline
XML:android:baselineAlignedChildIndex="0"
JAVA:linearLayout.setBaselineAlignedChildIndex(0);
代码:⭐注意内部的LinearLayout,后面将在 第二个LinearLayout上添加 baselineAlignedChildIndex ,搭配 baselineAligned="false" 使用
效果:
@H_ 895_ 419@
⭐ summary