我有三個元素的佈局,其方向是'水平'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