Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 具有可绘制背景的视图不';不显示在布局上_Java_Android_Xml_Android Listview - Fatal编程技术网

Java 具有可绘制背景的视图不';不显示在布局上

Java 具有可绘制背景的视图不';不显示在布局上,java,android,xml,android-listview,Java,Android,Xml,Android Listview,我正在尝试为listView中的一行创建蓝色背景,但背景仅显示在XML预览中,而不是在运行应用程序时显示 行布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent

我正在尝试为listView中的一行创建蓝色背景,但背景仅显示在XML预览中,而不是在运行应用程序时显示

行布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <View android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@drawable/row_background"
        android:id="@+id/mBackground" />

    ...

</RelativeLayout>

...
背景布局:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <shape
        android:shape="rectangle"
        android:thicknessRatio="9"
        android:useLevel="false" >
        <solid android:color="#FF0000" />

    </shape>
</item>

所有其他视图都正常显示,我尝试了不同的方法在背景文件中绘制反应,但没有一种有效。
有人能帮帮我吗。

尝试在视图中使用固定宽度(而不是换行内容)。更改换行内容以匹配视图高度固定大小(eq.android:layout\u height=“20dp”)