我有一個項目的水平列表,我希望平均分享可用的屏幕寬度。有沒有什麼辦法讓Mvx.MvxLinearLayout尊重android:layout_weight?
以前我用索引綁定到每個項目和一個靜態LinearLayout與每個項目具有相同的layout_weight。
當我用Mvx.MvxLinearLayout和ItemsSource綁定替換靜態LinearLayout,並將項目的標記移動到Itemtemplate中時,MvxLinearLayout不再考慮layout_weight。
我已經嘗試過重構項目模板的各種方式,並且在安排項目時似乎沒有辦法讓這個控件服從layout_weight。
有沒有什麼辦法讓Mvx.MvxLinearLayout尊重android:layout_weight,或者任何可以給我一個動態列表項目的動態列表,這些列表項目會按照固定維度的邊界進行平等安排?
編輯
假設3項列表,一個字符串屬性 '名稱'。
此標記按預期工作,給予同等寬度的3文本項:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxBind="Text Items[0].Name"
/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxBind="Text Items[1].Name"
/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxBind="Text Items[2].Name"
/>
</LinearLayout>
這個方法行不通,佈局權重不正確應用到TextViews:
<Mvx.MvxLinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="ItemsSource Items"
local:MvxItemTemplate="@layout/item_template" />
的ItemTemplate佈局文件:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxBind="Text Name" />
請包括一些以前的工作和你已經嘗試過的代碼。層次結構查看器顯示的差異是什麼? – Stuart
我已經添加了請求的信息,任何人都可以幫忙嗎? – Dave
是否有解決此問題的方法?我目前面臨同樣的問題。有一個MvxLinearLayout不尊重其中的項目layout_weight。 – Nexus2k