Android ListView项问题

Android ListView项问题,android,listview,Android,Listview,我的自定义ListView有问题。列表中的项目与列表的宽度不匹配,我不知道为什么 也许这幅画对你有帮助 列表视图: android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:id="@+id/linearLayout1" android:layout_height="wra

我的自定义ListView有问题。列表中的项目与列表的宽度不匹配,我不知道为什么

也许这幅画对你有帮助

列表视图:
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical">
    <LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="match_parent" android:gravity="center_vertical" android:background="#626262">
        <AutoCompleteTextView android:id="@+id/autoCompleteTextView1" android:layout_width="match_parent" android:layout_weight="2" android:layout_height="45dip" android:layout_marginTop="2dip"></AutoCompleteTextView>
        <ImageView android:id="@+id/imageView1" android:src="@drawable/lupe" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
    </LinearLayout>
    <LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content" android:layout_height="match_parent">
        <ListView 
            android:id="@+id/android:list" 
            android:background="#000000" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:cacheColorHint="#FFFFFF"
            android:layout_weight="1" />
    </LinearLayout>
</LinearLayout>
android:layout\u width=“match\u parent” android:layout\u height=“match\u parent”android:orientation=“vertical”> 行:


OnClick xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_deselect" />
<item android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_focus" />
<!-- Focused states -->
<item android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_deselect" />
<item android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_focus" />
<!-- Pressed -->
<item android:state_pressed="true"
android:drawable="@drawable/msg_bg_focus" />
</selector>

有人能帮忙吗


谢谢。

您的项目布局应该将布局宽度设置为填充父级而不是包装内容。

您的项目布局应该将布局宽度设置为填充父级而不是包装内容。

Gregory是对的。填充父对象。但如果这是一个图像,你也必须做一些工作。取决于图像的缩放设置方式

格雷戈里是对的。填充父对象。但如果这是一个图像,你也必须做一些工作。取决于图像的缩放设置方式

向我们展示您的代码或XML布局定义。稍后,我太傻了,不会在这里发布代码。o向我们展示您的代码或XML布局定义。稍后,我太傻了,不会在这里发布代码。o
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_deselect" />
<item android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_focus" />
<!-- Focused states -->
<item android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_deselect" />
<item android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/msg_bg_focus" />
<!-- Pressed -->
<item android:state_pressed="true"
android:drawable="@drawable/msg_bg_focus" />
</selector>