为什么内圆填充外圆? [英] Why does the inner circle fill the outer circle?

查看:125
本文介绍了为什么内圆填充外圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Android中的xml在较大的浅色圆圈中创建一个较小的深色圆圈.两个圆圈都有颜色,大小和笔触.为什么小黑圈填充了50 dp而不是28 dp?

I'm trying to make a small dark circle within a large light circle using xml in Android. Both circles have a color, a size and a stroke. Why does the small dark circle fill the 50 dp instead of being 28dp?

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!--big light circle-->
    <item>
        <shape android:shape="oval">
            <solid android:color="#EEEEEE" />

            <size
                android:width="50dp"
                android:height="50dp" />

            <stroke
                android:width="2dp"
                android:color="#404040" />
        </shape>
    </item>
    <!--small dark circle-->
    <item>
        <shape android:shape="oval">
            <solid android:color="#AEAEAE" />

            <size
                android:width="28dp"
                android:height="28dp" />

            <stroke
                android:width="1dp"
                android:color="#464646" />
        </shape>
    </item>
</layer-list>

可绘制对象的用法:

   <RadioButton
        android:id="@+id/radioButtonPositive"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:button="@android:color/transparent"
        android:drawableTop="@drawable/ic_choice_background"
        android:gravity="center"
        android:onClick="onRadioButtonClicked"
        android:layout_marginRight="110dp"/>

xml生成,但我希望它生成 (外圈大小相同,此屏幕截图无法正确显示)

The xml generates But I want it to generate (the outer circles are the same size, this screenshot doesn't show it correctly)

推荐答案

更改为以下

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--big light circle-->
<item>
    <shape android:shape="oval">
        <solid android:color="#EEEEEE" />

        <size
            android:width="50dp"
            android:height="50dp" />

        <stroke
            android:width="2dp"
            android:color="#404040" />
    </shape>
</item>
<!--small dark circle-->
<item android:bottom="11dp"
    android:left="11dp"
    android:right="11dp"
    android:top="11dp">
    <shape android:shape="oval">
        <solid android:color="#AEAEAE" />

        <stroke
            android:width="1dp"
            android:color="#464646" />
    </shape>
</item>

这篇关于为什么内圆填充外圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆