2012-07-06 80 views
1

我有圓角的列表視圖。我怎樣才能設置這些角落的背景?我需要將它們設置爲灰色,如主背景,但它們是白色的。Android:列表視圖角落的背景

enter image description here

我的列表視圖

<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> 
+0

你在設備或模擬器中檢查過嗎? – 2012-07-06 13:55:49

+0

此快照來自仿真器 – yital9 2012-07-06 13:57:23

+0

仿真器不會顯示轉換框。我相信圖形佈局。 – 2012-07-06 13:58:24

回答

3

是否可以設置您的XML形狀透明的背景是什麼? 您可以使用系統默認

@android:color/transparent 
+0

形狀中沒有背景屬性 – yital9 2012-07-06 13:58:02

+0

好的。你可以嘗試在第一個位置添加。而不是000000使用你的灰色陰影? – 2012-07-06 14:01:11

+0

嘗試,但沒有任何變化 – yital9 2012-07-06 14:04:05

1

嘗試跟隨着加入befor增加的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" 
      /> 

我檢查了它,它的工作原理。