简体   繁体   English

在xml文件中创建多个矩形形状

[英]Create multiple rectangle shape in a xml file

I have create a shape.xml in android project. 我在android项目中创建了shape.xml。 In this xml file i have a rectangle shape design with border.This is working fine. 在这个xml文件中,我有一个带边框的矩形设计。 I need to create a another rectangle shape with left border in the same xml. 我需要在同一xml中创建另一个具有左边框的矩形。 Is this possible or not. 这可能与否。 If its possible means how can i refer the two diff shape in layout page. 如果可能的话,我如何在布局页面中引用两个diff形状。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <shape android:shape="rectangle" >
        <stroke
            android:height="2dp"
            android:width="2dp"
            android:color="#FF0000" />

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

        <padding
            android:bottom="1dp"
            android:left="1dp"
            android:right="1dp"
            android:top="1dp" />

        <corners
            android:bottomLeftRadius="0dp"
            android:bottomRightRadius="5dp"
            android:radius="1dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="0dp" />
    </shape>
</item>
http://stackoverflow.com/questions/4740538/can-i-use-multiple-shapes-in-one-android-drawable
http://stackoverflow.com/questions/5702143/multipe-shapes-inside-shapes-xml-in-android

<?xml version="1.0" encoding="utf-8"?>
<layer-list>
<item android:drawable="@drawable/shape_7"/>
<item android:drawable="@drawable/shape_1"/>
</layer-list>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM