如何在 XML 中定义 MaterialShapeDrawable - Android

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

我想在我的 Android 项目的 /res/drawable 中的 XML 文件中使用漂亮的 MaterialShapeDrawable,但是每当我尝试像 /layout/ XMLs 中的视图那样定义它时,我会看到:

Element com.google.android.material.shape.MaterialShapeDrawable is not allowed here 

尝试时:

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorPrimary">
    <item>
        <com.google.android.material.shape.MaterialShapeDrawable />
    </item>
</ripple>`

有没有什么方法可以使用 XML 来简化这项工作?我必须添加什么样的命名空间?

android xml vector material-design android-drawable
© www.soinside.com 2019 - 2024. All rights reserved.