Android背景底部

时间:2013-12-30 12:20:05

标签: android android-layout

我想实现LinearLayout的背景。 LinearLayout的背景 包含LinearLayout底部带有浅色边框的图像重复。我在LinearLayout的背景处实现了图像重复,但无法在LinearLayout的底部添加边框。我尝试了很多解决方案,但无法成功。

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  



     <item android:drawable="@drawable/bitmaprepeat" />
    <item  android:bottom="1px"  android:id="@android:id/background">
        <shape> 
            <solid/>
           <stroke android:width="1px" android:color="#dddddd" />  

        </shape>
    </item>
   </layer-list>

其中bitmaprepeat是一个drawable,我在后台重复图像

1 个答案:

答案 0 :(得分:1)

要显示底部边框,您需要从底部为最后一项添加填充,如下所示

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape>
            <solid android:color="#ff0000"/>
        </shape>
    </item><!-- Lower Drawable -->

    <item android:bottom="10px">
         <shape>
            <solid android:color="#00ff00"/>
        </shape>
    </item><!-- Upper Drawable, Use your drawable here like android:drawable="@drawable/img" in <item> tag-->

</layer-list>

您可以在附加图像上看到输出。 enter image description here

相关问题