我有三个元素的布局,其方向是'水平'android weightSum无法正常工作
我想修复每个元素在我的布局中占用的大小。
第一个元素占总空间的40%,第二个元素占5%,第三个占据剩余55%的空间。
我的布局是这样的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="@+id/outletname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="40"
android:text="@string/outlet_name2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:text=": " />
<TextView
android:id="@+id/outletnamevalue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="55"
android:text="abcdefttt" />
</LinearLayout>
</LinearLayout>
文本“的TextView”会动态变化,所以我要继续为不论意见的内容元素不变的空间...
完成答复,必须了解的是,重量仅适用于/ /剩余空间,即左一旦施加的layout_width值空间。 – njzk2 2012-04-11 09:53:03
这使我的一天:D多少年...... LOL。所以这是问题的唯一答案。 UPVOTEEEEEEE – jace 2017-04-19 03:44:39