ListView不是全宽

时间:2015-10-06 15:33:00

标签: android xml listview

我在Frame Layout中创建了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"
/>

我的问题是ListView项目不是屏幕宽度的100%,只是标签的宽度

我需要改变什么?

enter image description here

2 个答案:

答案 0 :(得分:1)

android:layout_width="wrap_content"更改

android:layout_width="match_parent"

var checkBoxTemplate = '<div class="ngCellText text-center" ng-cell-text ng-class="col.colIndex()" ' + 'style="height: 100%;vertical-align: middle"> ' + ' <span ng-show="COL_FIELD" class="glyphicon glyphicon-ok" style="margin-top: 6px;"/> ' + '</div> ';

答案 1 :(得分:0)

尝试删除android:gravity="center_vertical"上的ListView并在android:layout_width="match_parent"上设置wrap_content而不是TextView