简体   繁体   English

Android:Vector Asset不会出现

[英]Android: Vector Asset does not appear

I'm using Vector Asset on my application. 我在我的应用程序上使用Vector Asset The icon I'm used does not appear in one of my phones and I don't know how to solve this issue. 我使用的图标没有出现在我的一部手机中,我不知道如何解决这个问题。 One of the mobiles has android version 8.1 (API 27) and the icon appears and the other has version 6.0.1 (API 23) and the icon does not appear. 其中一个手机有Android版本8.1(API 27),图标出现,另一个版本6.0.1(API 23),图标不出现。 I've searched, the Vector Asset is supported since version 20. What can I do to the icon appears on my android version 6.0.1 phone? 我搜索过,从版本20开始支持Vector Asset。我的android版6.0.1手机上是否可以显示该图标?

Vector asset code: 矢量资产代码:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="54dp"
    android:height="54dp"
    android:viewportWidth="35.68696"
    android:viewportHeight="35.68696">
      <group android:translateX="5.843478"
          android:translateY="5.843478">
            <path
                android:strokeWidth = "1"
                android:strokeColor="#A0A0A0"
                android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
      </group>
</vector>

I've included vectorDrawables.useSupportLibrary = true in build.gradle . 我在build.gradle包含了vectorDrawables.useSupportLibrary = true

I use these in one of my projects and at one point could not get it to work on older versions. 我在我的一个项目中使用这些,并且有时无法让它在旧版本上运行。 I added this to my MainActivity and it worked. 我将此添加到我的MainActivity中并且它有效。

 static {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

My post may have been incomplete, the link where I found what worked for me was here. 我的帖子可能不完整,我发现对我有用的链接就在这里。 It may be worth checking out: 可能值得一试:

SO link SO链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM