专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Android

请教怎么平均等分LinearLayout的宽度

发布时间:2010-05-30 10:55:54 文章来源:www.iduyao.cn 采编人员:星星草
请问如何平均等分LinearLayout的宽度?
书上介绍说可以用权重android:weightSum对LinearLayout进行比例划分,但是不行啊。
比如LinearLayout上有三个textview,每个textview的android:layout_weight="1";
如果每个textview的text的内容长度是一致的,就可以等比划分,但是text的长度不一样就不行了啊。

------解决方案--------------------
textview设置:
android:layout_width="fill_parent"
android:layout_weight="1"
试试看
------解决方案--------------------
<?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="38dip"
android:background="#0000AA"
android:orientation="horizontal" >

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:maxLines="1"
android:background="#FF0000"
android:hint="好好学习,天天向上"
android:singleLine="false" />

<TextView
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:background="#FFFF00"
android:text="无" />

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#F55F00"
android:text="无tryrd yui" />

</LinearLayout>
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: