【问题标题】:RuntimeException : Width (0) and height (0) cannot be <= 0RuntimeException : 宽度 (0) 和高度 (0) 不能 <= 0
【发布时间】:2020-03-11 06:16:30
【问题描述】:

我遇到了这种类型的错误,我该如何解决这个问题。

java.lang.RuntimeException: java.lang.RuntimeException: Error while 处理 D:\Android Project\AttendanceApp\app\src\main\res\drawable\ic_arrow_back.xml : 宽度 (0) 和高度 (0) 不能

ic_arrow_back.xml

<vector android:height="@dimen/_25sdp" android:tint="#FFFFFF"
    android:viewportHeight="24.0" android:viewportWidth="24.0"
    android:width="@dimen/_25sdp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FF000000" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

【问题讨论】:

  • 发布你的 ic_arrow_back.xml
  • 更新了我的答案
  • 你启用了vectorDrawables.useSupportLibrary = true 吗?

标签: android android-layout android-imageview


【解决方案1】:

您需要在应用的 build.gradle 中添加某些属性。

android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 } 

【讨论】:

  • 2021 年默认情况下如何做到这一点真是太疯狂了
【解决方案2】:

尝试在你的 build.gradle 中启用vectorDrawables.useSupportLibrary

 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 } 

在您的 layout.xml 中:

 <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srcCompat ="@drawable/ic_arrow_back"
        />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多