首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

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

2012-03-14 
请问如何平均等分LinearLayout的宽度?书上介绍说可以用权重android:weightSum对LinearLayout进行比例划分,

请问如何平均等分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>

热点排行