LinearLayout布局时使用右对齐android:layout_gravity="right")控件对齐方式不生效,需要设置 android:layout_weight="1" 才能右对齐控件,原因在于后者把位置平分了。

 

<</span>LinearLayout android:gravity="right" android:layout_margin="2dip"

       android:orientation="horizontal" android:layout_gravity="center_vertical"

       android:layout_width="wrap_content" android:layout_height="wrap_content"

       android:layout_weight="1" >

 

       <</span>Button android:id="@+id/btnCommonExpress" android:width="50dip"

           android:layout_width="wrap_content" android:layout_height="wrap_content"

           android:layout_alignParentRight="true" android:text="常用" />

       <</span>Button android:id="@+id/btnAll" android:width="50dip"

           android:layout_width="wrap_content" android:layout_height="wrap_content"

           android:layout_alignParentRight="true"android:layout_alignRight="@+id/btnCommon"

           android:text="所有" />

 </</span>LinearLayout>

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-10-18
  • 2022-01-29
  • 2021-05-21
猜你喜欢
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
相关资源
相似解决方案