android列表项';s具有圆角的子视图

android列表项';s具有圆角的子视图,android,list,rounded-corners,Android,List,Rounded Corners,我正在开发一个闹钟应用程序。我想要一个列出所有现有报警的活动。我正在为ListView的每一行使用自定义布局。它应该显示报警的描述、类型和时间 以下是行布局:alarm_item_2.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width

我正在开发一个闹钟应用程序。我想要一个列出所有现有报警的活动。我正在为ListView的每一行使用自定义布局。它应该显示报警的描述、类型和时间

以下是行布局:alarm_item_2.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="@drawable/selector">
    <TextView
        android:id="@+id/time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/time_background"
        android:textColor="#ffffff"
        android:layout_marginTop="6dp"
        android:layout_marginLeft="6dp"
        android:layout_marginRight="6dp"
        android:padding="6dp"
        android:textSize="36sp"
    />
    <TextView
        android:id="@+id/description"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@id/time"
        android:paddingTop="6dp"
        android:textStyle="bold"
        android:textSize="20sp"
        android:textColor="#000"
    />
    <TextView
        android:id="@+id/type"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/time"
        android:layout_below="@id/description"
        android:textSize="18sp"
        android:textColor="#000"
    />
</RelativeLayout>

还有活动的布局:view_alarms.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical"
          >
<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:cacheColorHint="#fff"
    android:background="#fff"
    android:drawSelectorOnTop="true"
/>
</LinearLayout>

我想要的是使显示时间的视图为黑色,并带有圆角。我正在res/drawable文件夹中使用形状资源:time\u background\u xml:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="#000000"/>
    <corners android:radius="10dp"/>
</shape>


但是,按钮的背景仍为白色。我的代码有什么问题?显然,我遗漏了一些重要的东西。

我认为时间背景xml应该是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#000000"/>    
            <corners android:radius="10dp"/>
        </shape>
    </item>    
</layer-list>

请查看以获取更多帮助

更新:

我认为这会奏效:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> 
    <solid android:color="#000000"/>    

    <stroke android:width="3dp"
            android:color="#000000"/>

    <padding android:left="1dp"
             android:top="1dp"
             android:right="1dp"
             android:bottom="1dp"/> 

    <corners android:radius="10dp"/> 
</shape>


另外,请查看其他解决方案。

它不起作用。背景仍然是透明的。用于绘制多个项目时效果很好,但在我的布局中,我只需要一个带圆角的黑色矩形,因此简单的绘制通常就足够了。