关于android自定义drawable中gradient的属性报错问题

起因:实现第二个样式时

报错如下:

FATAL EXCEPTION: main
                                                                    Process: com.company.exam03, PID: 11577

                                                                    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.exam03/com.company.exam03.MainActivity}: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class Button


出错位置:

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/test1"
    android:text="测试" />

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:bottomLeftRadius="8dp"/>
    <corners android:bottomRightRadius="8dp"/>
    <corners android:topLeftRadius="8dp"/>
    <corners android:topRightRadius="8dp"/>
    <corners android:radius="8dp"/>
    <gradient android:startColor="#092fda"
        android:endColor="#ffffff"
        android:type="radial"
        />
</shape>

原因:

API中查询得知

android:gradientRadius

Float. The radius for the gradient. Only applied when  android:type="radial".配置gradient type="radial"时 必须配置gradientRadius属性。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值