2015-11-03 106 views
0

更改背景我有我的應用程序註釋活動佈局圓角繪製背景(layout_bg_round_corners):安卓的繪製

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="@color/deep_orange"/> 
    <corners android:radius="20dip"/> 
    <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /> 
</shape> 

提拉閃耀的通過爲白色背景。相反,我希望他們是黑人。

如何設置drawable的背景顏色?

comment

這是我如何設定父視圖的佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="@drawable/layout_bg_round_corners" 
+0

你意味着可繪製父視圖的背景?只需將該視圖的背景顏色設置爲黑色即可:android:background =「#000000」 – mjp66

+0

因爲您必須將drawables父視圖設置爲drawable,所以您不能獲得圓角,並且整個視圖也會變黑。 – Simon

+0

然後,可繪製的圖層列表聽起來像是一個計劃。我會張貼一個樣本。 – mjp66

回答

1

除非我已經完全誤解了你,層列表繪製應該做的伎倆:)

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item> 
     <shape> 
      <solid android:color="#000000" /> 
     </shape> 
    </item> 

    <item> 
     <shape> 
      <solid android:color="@color/deep_orange"/> 
      <corners android:radius="20dip"/> 
      <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /> 
     </shape> 
    </item> 

</layer-list> 
+0

完美。它做了詭計。謝謝。 3分鐘過後,我會接受你的回答。 – Simon

0

在佈局XML添加標籤的android:背景= 「顏色代碼

或者你可以通過用可繪製的ID替換顏色代碼來將背景設置爲可繪製的。

+0

這就是我所做的 - 我已將背景設置爲可反映深橙色的可繪製背景。我無法將黑色設置爲可繪製的背景顏色。 – Simon

1

嘿,你需要給黑顏色相對佈局,試試這個

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:tools="http://schemas.android.com/tools" 
android:background="#000000"> 
<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/layout_bg_round_corners"> 
+0

另一種可能的解決方案。謝謝。 – Simon