2013-08-22 100 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

那是一个聪明的办法我猜! –