我可以将图像放在我的drawable
文件夹中并毫无问题地使用它。
但我想使用不同大小的图像(mdpi
,hdpi
等)。
因此,我尝试使用Android Studio中的Image Asset
生成此图像的不同大小版本。
如果Icon Type
是Launcher Icons
,则生成器工作得很好,但输出是mipmap
(应用程序的启动器图标)。
如果我选择正确的Icon Type
输出目标是drawable
文件夹,但遗憾的是生成的图标只是一个圆圈。
我想Android Studio告诉我,我必须使用向量而不是图像来处理将在ActionBar中使用的图标。这样对吗?
所以我从Clip Arts
中选择了一个预定义的图标:
但Shape
没有Action Bar and Tab Icons
选项。这将是伟大的,但它只适用于Launcher Icons
。
最后我的问题可归纳为:
back arrow
工具生成带有circle shape
的Image Asset
吗?drawable resource
来获得一个圆形按钮。但在性能方面,1矢量+ 1可绘制资源优于1图像具有不同的分辨率?先感谢您。
请给我一些想法来理解它。
Here也许这会对你有所帮助。
只是为了解决你的问题。请看一下这个CircularContactView链接。您可以从资源生成后向箭头作为drawable,然后您可以使用上面的CircularContactView类的实例来适应其中的箭头。
像这样的东西:
circularContactViewObj.setImageResource(R.drawable.your_back_arrow, Color.YOUR_COLOR);
你也使用如下的矢量图像
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#28274b"
android:strokeWidth="1"
android:pathData="M21.49 12.28C21.49 17.58 17.22 21.89 11.96 21.89C6.7 21.89 2.43 17.58 2.43 12.28C2.43 6.98 6.7 2.68 11.96 2.68C17.22 2.68 21.49 6.98 21.49 12.28Z" />
<!--<path
android:fillColor="#ffffff"
android:strokeWidth="1"
android:pathData="M12.1 7.19L5.72 11.99L12.1 16.8L12.1 13.75L18.87 13.75L18.87 10.23L12.1 10.23L12.1 7.19Z" />-->
<path android:fillColor="#ffffff" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>