我在HorizontalScrollView中有Listview。該列表視圖保存文件路徑,水平滾動視圖旨在消除包裝較長路徑的需要。Android ListView切斷比第一項更寬的項目
所有的工作都完全按照需要進行,除了在第一個項目的長度上,比第一個項目更長的任何項目被剪切(不管第一個項目的寬度是多少,其他項目都不會滾過那個寬度)。
這是給我找麻煩佈局的部分:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layoutListView"
android:orientation="vertical"
android:layout_below="@+id/spFileTypes">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1">
<ListView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/lvItems"/>
</HorizontalScrollView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:id="@+id/tvStatus"/>
</LinearLayout>
這是問題的一個截圖:
圖片一路滾動到對。第三項是切斷「.php」。我已經嘗試過使用長短文件名,很多(上面的兩位數字)列表以及幾個列表,在每種情況下,寬度限制似乎取決於第一項的寬度。
每當列表發生變化時,它總是限制其寬度,無論第一個元素是什麼。
希望的行爲是讓它匹配最寬項目的寬度。
我把我的心挖出來,通過官方文檔挖出來,我很難過。任何幫助是極大的讚賞:)
HorizontalScrollView的layout_weight = 1,而LinearLayout中的第二個孩子沒有。您應該將權重添加到TextView或從ListView中刪除它。希望它是幫助。 –
我會記下這一點,但TextView完全按照需要顯示在屏幕上(屏幕截圖只是爲了顯示特定的切斷行爲) – BMB