我正在为 Android 实现这样的 ListView 。
不用担心选择器和每个项目左侧的细条,列表项的可绘制背景布局将是:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="1dp" android:color="#000000" />
<corners
android:bottomRightRadius="27dp"
android:topRightRadius="27dp" />
</shape>
我将其命名为 list_border.xml
,它位于可绘制文件夹中。
我尝试将其设置为 ListView 的背景
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/list_padding"
android:paddingRight="@dimen/list_padding"
android:divider="@drawable/list_border"/>
并作为每个列表项的背景
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@drawable/list_border" >
<ImageView
android:id="@+id/menu_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/arrow1_e" />
<org.bitbucket.infovillafoundation.denko.customui.MyanmarTextView
android:id="@+id/menu_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/menu_icon" />
</RelativeLayout>
但是 ListView 没有改变以反射(reflect)新的背景。有什么问题吗?
最佳答案
对于 ListView ,您将其设置为分隔符而不是背景。检查并改正
关于Android ListView 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29870379/