我是靠谱客的博主 大胆水杯,这篇文章主要介绍解决LinearLayout中控件不能居右对齐,现在分享给大家,希望可以做个参考。

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>

最后

以上就是大胆水杯最近收集整理的关于解决LinearLayout中控件不能居右对齐的全部内容,更多相关解决LinearLayout中控件不能居右对齐内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部