使用Image Asset(Android Studio)在圆圈内生成箭头

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

我想在ActionBar中使用下一个图像:enter image description here

我可以将图像放在我的drawable文件夹中并毫无问题地使用它。

但我想使用不同大小的图像(mdpihdpi等)。

因此,我尝试使用Android Studio中的Image Asset生成此图像的不同大小版本。

如果Icon TypeLauncher Icons,则生成器工作得很好,但输出是mipmap(应用程序的启动器图标)。

enter image description here

如果我选择正确的Icon Type输出目标是drawable文件夹,但遗憾的是生成的图标只是一个圆圈。

enter image description here


我想Android Studio告诉我,我必须使用向量而不是图像来处理将在ActionBar中使用的图标。这样对吗?

所以我从Clip Arts中选择了一个预定义的图标:

enter image description here

Shape没有Action Bar and Tab Icons选项。这将是伟大的,但它只适用于Launcher Icons

最后我的问题可归纳为:

  1. 有一种方法可以使用Android Studio中的back arrow工具生成带有circle shapeImage Asset吗?
  2. 我想我可以使用箭头图标并另外应用drawable resource来获得一个圆形按钮。但在性能方面,1矢量+ 1可绘制资源优于1图像具有不同的分辨率?

先感谢您。

请给我一些想法来理解它。

android android-studio vector android-drawable
4个回答
1
投票

似乎Image Asset不提供正常图标的设置背景。这个问题有多种解决方案,最简单的就是去here,找到你想要的图标。这将生成所有不同的大小。

此外,您可以使用Photoshop制作图像并从here生成其图标

希望能帮助到你


1
投票

Here也许这会对你有所帮助。


0
投票

只是为了解决你的问题。请看一下这个CircularContactView链接。您可以从资源生成后向箭头作为drawable,然后您可以使用上面的CircularContactView类的实例来适应其中的箭头。

像这样的东西:

circularContactViewObj.setImageResource(R.drawable.your_back_arrow, Color.YOUR_COLOR);


0
投票

你也使用如下的矢量图像

    <?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"/>

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