Android AppWidget ListView元素高度不包含内容

时间:2016-01-28 12:10:33

标签: android listview

我正在使用ListView使用RemoteViewsFactory构建应用小部件,一切正常但我有一个问题,我的列表行不包含内容,例如,如果元素是图像,它们适合行空间,但如果我只有文本视图,则视图和行尾之间会有很多空白空间。对于父布局,ListView layout_heightwrap_content,对于列表中的自定义元素,我有这样的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="2">

    <TextView
        android:id="@+id/custom_txt1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/widget_border"/>

    <TextView
        android:id="@+id/custom_txt2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:background="@color/md_red_900" />
</LinearLayout>
...
</RelativeLayout>

0 个答案:

没有答案