1

我有圆角的列表视图。如何设置这些角落的背景?我需要将它们设置为灰色,就像主背景一样,但它们是白色的。

在此处输入图像描述

我的列表视图

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/cats_list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:cacheColorHint="#000"
            android:background="@drawable/round_corners"
            />

round_corners.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
     android:topLeftRadius="17dp" android:topRightRadius="17dp"/> 

    <gradient
        android:angle="180"
        android:endColor="#ff0000"
        android:startColor="#ff0000"
        android:type="linear" />

</shape>
4

2 回答 2

3

是否可以将您的 xml 形状的背景设置为透明?可以使用系统默认

@android:color/transparent 
于 2012-07-06T13:55:16.753 回答
1

在添加 ListView 之前尝试以下添加视图的技巧。该视图的背景颜色为灰色。

<View
        android:background="@android:color/darker_gray"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/cats_list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:cacheColorHint="#000"
            android:background="@drawable/round_corners"
            />

我检查了它,它可以工作。

于 2012-07-06T14:14:50.163 回答