2015-10-06 58 views
-1

我在框架佈局創造了一個ListView項:的ListView不是全寬

home_activity.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".Home"> 

<ListView 
    android:id="@+id/home_item_list" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical"> 
</ListView> 
</FrameLayout> 

home_list_item.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/home_item_activity_selector_textview" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:gravity="center_vertical" 
android:minHeight="?android:attr/listPreferredItemHeight" 
android:paddingLeft="15dp" 
/> 

我proble是,ListView項不是屏幕寬度的100%,只有標籤的寬度

我必須改變什麼?

enter image description here

+0

'的android:layout_width = 「WRAP_CONTENT」'? – njzk2

+0

@ njzk2不,我想盡一切可能 –

回答

0

嘗試在ListView刪除android:gravity="center_vertical"TextView設置android:layout_width="match_parent"而不是wrap_content

+1

仍然不能正常工作 –

+0

你可以附上截圖嗎? – mixel

+1

添加了截圖,可以看到我的觸摸,不可能觸及非灰色區域 –

1

在你home_list_item.xml變化

android:layout_width="wrap_content"

android:layout_width="match_parent"

+0

我同意。根據OP提供的信息,這是最可能的解決方案 – njzk2

+0

我認爲存在一個錯誤,有時可行,有時候不行 –

+0

我在我的答案中提出了完全相同的解決方案。 – mixel