gpt4 book ai didi

android - 在 android :drawableTop before API level 21 中使用矢量图像

转载 作者:行者123 更新时间:2023-11-29 19:29:46 26 4
gpt4 key购买 nike

我正在开发一个需要在 Android 设备上一直运行到 Android Gingerbread (2.3) 的应用程序,并且似乎在显示 SVG 图像时遇到了一些问题。

我明白,支持库允许我通过在我的应用程序级别 build.gradle 中删除此行来使用矢量图像:

vectorDrawables.useSupportLibrary = true

然后我可以使用各种支持库类或 android:srcCompatImageView

中显示 SVG

这里的问题是我没有使用 ImageView 来显示我的 SVG。我正在使用带有 android:drawableTop 属性的 TextView 来显示我的 SVG,如下所示:

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text_no_notes"
android:textAlignment="center"
android:drawableTop="@drawable/ic_notepad"
android:id="@+id/textView"
android:textAppearance="@style/TextAppearance.AppCompat.Medium.Inverse" />

由于 android:drawableTop 不使用支持库矢量图像,应用程序在“L”之前的设备上运行时崩溃。有没有我可以用来让 android:drawableTop 工作的解决方法,或者我是否只是拆分 TextView 并使用 android:srcCompat

最佳答案

系统TextView无法使用。 (相关源码:5.1.1/4.4.4)

您可以使用自定义 View 类,但此时我认为您最好使用带有 ImageView 和 TextView 的 LinearLayout。

关于android - 在 android :drawableTop before API level 21 中使用矢量图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40325106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com