请问如何平均等分LinearLayout的宽度?

loskill 2011-12-20 06:58:18
书上介绍说可以用权重android:weightSum对LinearLayout进行比例划分,但是不行啊。
比如LinearLayout上有三个textview,每个textview的android:layout_weight="1";
如果每个textview的text的内容长度是一致的,就可以等比划分,但是text的长度不一样就不行了啊。
...全文
3700 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
原来是fp+权重,我试了3个小时了,各种试,文档我也看了,说是全设成0再设权重,根本就是扯
阿提饭 2011-12-21
  • 打赏
  • 举报
回复
<?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>
dontsaymiss 2011-12-21
  • 打赏
  • 举报
回复
textview设置:
android:layout_width="fill_parent"
android:layout_weight="1"
试试看

80,362

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧