我是靠谱客的博主 单薄翅膀,这篇文章主要介绍(转)LinearLayout中实现水平方向上的两个Textview一个居左,一个居右的效果,现在分享给大家,希望可以做个参考。

原地址:http://blog.csdn.net/lb1207087645/article/details/49819453


我们知道,在LineraLayout中,当设置android:orientation="horizental" ,子控件的android:layout_gravity="left",android:layout_gravity="right"是无效的,所以我们可以改用比重的方法来达到两个textview一个居左,一个居右的效果,如下这种效果


复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="张三"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="李四"/> </LinearLayout>

设置 android:layout_width="0dp",android:layout_height="wrap_content",android:layout_weight="1"这三个属性后,就会把match_parent剩下的布局给撑满,所以会把右边那个textView挤到最右端。
这样就能达到在LinLinearLayout中水平方向上的有两个textview一个居左,一个居右的效果。

最后

以上就是单薄翅膀最近收集整理的关于(转)LinearLayout中实现水平方向上的两个Textview一个居左,一个居右的效果的全部内容,更多相关(转)LinearLayout中实现水平方向上内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部