2013-08-22 27 views
0

問題:A LinearLayout應具有不同的背景(帶白色的顏色)和深色輪廓。造型佈局輪廓

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape = "rectangle"> 
    <corners 
     android:radius="2dp" 
     android:topRightRadius="0dp" 
     android:bottomRightRadius="0dp" 
     android:bottomLeftRadius="0dp" /> 
    <stroke 
     android:width="1dp" 
     android:color="#000000" /> 

</shape> 

我嘗試什麼:以下代碼被稱爲在佈局文件中的元素"android:background"。這樣做不允許我的LinearLayout有我想要的白色背景,但獲得了黑色輪廓。關於如何實現兩者的任何想法? 幫忙:)

回答

1

你也可以試試這個

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape = "rectangle"> 
    <corners 
     android:radius="2dp" 
     android:topRightRadius="0dp" 
     android:bottomRightRadius="0dp" 
     android:bottomLeftRadius="0dp" /> 
    <stroke 
     android:width="1dp" 
     android:color="#000000" /> 
    <gradient android:startColor="#FFFFFF" 
    android:endColor="#FFFFFF" 
    android:angle="90"/> 

</shape> 
1

把你的LinearLayout放在FrameLayout的裏面。給黑色背景FrameLayout。給予LinearLayout白色背景。設置LinearLayout's保證金1dp

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@android:color/black" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_margin="1dp" 
     android:background="@android:color/white" > 

     .... 
     .... 

    </LinearLayout> 

</FrameLayout> 
+0

那是一個聰明的辦法我猜! –