Android的Android奇怪行为:top& android:正确定义的形状

时间:2015-07-17 22:27:58

标签: android android-shape

我有一个形状:

<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="#000000"></solid>
    </shape>
</item>

<item
    android:top="12dp"
    android:bottom="12dp">
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <corners android:radius="15dp"></corners>
        <solid android:color="#000000"></solid>
        <stroke
            android:width="5dp"
            android:color="#ffffff"></stroke>

        <padding
            android:bottom="12dp"
            android:left="12dp"
            android:right="12dp"
            android:top="12dp" />
    </shape>
</item>

  

看起来不错:

enter image description here

但是当我添加android:right时,它看起来很奇怪:

enter image description here

当我添加所有选项(顶部,左侧,右侧,底部)时:

enter image description here

最终代码:

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

    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
            <solid android:color="#000000"></solid>
        </shape>
    </item>

    <item
        android:top="12dp"
        android:bottom="12dp"
        android:right="2dp"
        android:left="2dp">
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
            <corners android:radius="15dp"></corners>
            <solid android:color="#000000"></solid>
            <stroke
                android:width="5dp"
                android:color="#ffffff"></stroke>

            <padding
                android:bottom="12dp"
                android:left="12dp"
                android:right="12dp"
                android:top="12dp" />
        </shape>
    </item>

</layer-list>

我做错了什么?

0 个答案:

没有答案