Android中LinearLayout布局的常用属性总结

2019-12-10 18:19:35丽君
易采站长站为您分析Android中LinearLayout布局的常用属性总结,包括居中、重心、比例等线性布局中的基本设置,需要的朋友可以参考下  

基本属性要求

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"

  android:orientation="vertical">
 </LinearLayout>

  • android:orientation
  • 决定是水平排列或是垂直排列
  • vertical 垂直排列
  • horizontal 水平排列

    垂直排列 Button

    <LinearLayout
      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="Button 1" />
      <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 2" />
    
    </LinearLayout>
    
    

    水平排列 Button

    <LinearLayout
      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="Button 1" />
      <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button 2" />
    
    </LinearLayout>