Java 具有可绘制背景的视图不';不显示在布局上
我正在尝试为listView中的一行创建蓝色背景,但背景仅显示在XML预览中,而不是在运行应用程序时显示 行布局: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
<?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”)