在XML中使用attr会导致Android崩溃

问题描述 投票:0回答:1

我在此XML中有一个可绘制对象:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:endColor="@color/transparent"
        android:gradientRadius="200dp"
        android:startColor="?attr/primaryDarkTransparent"
        android:type="radial" />
</shape>

[startColor使用?attr/primaryDarkTransparent时XML导致崩溃:

Caused by: java.lang.RuntimeException: org.xmlpull.v1.XmlPullParserException: <internal><gradient> tag requires 'gradientRadius' attribute with radial type Caused by: org.xmlpull.v1.XmlPullParserException: <internal><gradient> tag requires 'gradientRadius' attribute with radial type

[戏剧性的故事是,当我在attrsolid中使用stroke时,效果很好,但我不知道gradient中到底发生了什么。

任何建议将不胜感激。

android xml attr
1个回答
0
投票

shape中有两个问题。

© www.soinside.com 2019 - 2024. All rights reserved.