【安卓问题】自创drawable定长宽有多余空间(已解决)

安卓开发中,遇到了一个问题

过程

我写了一个drawable:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:width="60dp"
        android:height="60dp">
        <shape>
            <!-- 填充的颜色 -->
            <solid android:color="#00DDAA" />
            <corners android:radius="30dp" />
        </shape>
    </item>
</layer-list>

他的效果是:可以看出是圆的在这里插入图片描述
放在xml中:

<View
        android:id="@+id/test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:layout_marginTop="20dp"
        android:layout_marginStart="20dp"
        android:background="@drawable/point_image_checked"
        />

xml效果:
在这里插入图片描述
在这里插入图片描述

我不明白为什么除了drawable其他地方还有这么大的空间!明明view上用了wrap_content啊

啊 我知道问题在哪里了,xml用ImageView就好了。轴了轴了。
多年后的自己再看这个问题大概会想起自己的天真吧。

<ImageView
        android:id="@+id/test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:layout_marginTop="20dp"
        android:layout_marginStart="20dp"
        android:background="@drawable/point_image_checked"
        />
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值