线性布局-LinearLayout


  1. 线性布局不会换行,当组件一个挨着一个排列到头之后,剩下的组件将不会被显示出来。
  1. 线性布局中最重要的两个属性

android:orientation  设置布局管理器内组件的排列方式

      水平排列:horizontal                垂直排列:vertical

                android:gravity          设置布局管理器内组件的对齐方式

                     top|bottom|left|right|center_vertical|center_horizontal|center|…

  1. Android:gravity属性中的多个属性值之间可以用竖线隔开
<?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
="vertical"
    android:gravity
="center|left">

    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    <Button 
        
android:layout_width="80dp"
        android:layout_height
="wrap_content"/>
    

</LinearLayout>

相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-07-28
  • 2021-09-17
  • 2021-10-15
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2021-05-01
  • 2022-01-11
  • 2021-04-27
  • 2018-07-08
  • 2021-06-21
  • 2021-11-10
相关资源
相似解决方案