app:srcCompat不适用于ImageView

编程入门 行业动态 更新时间:2024-10-25 20:20:47
本文介绍了app:srcCompat不适用于ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在向库项目添加矢量可绘制支持,并使用app:srcCompat引用矢量可绘制.似乎起作用的唯一视图是ImageButton,我不确定为什么.

I'm adding vector drawable support to a library project, and using app:srcCompat to reference the vector drawable. The only view that appears to work is ImageButton and I'm not sure why.

这是我的build.gradle的相关部分

Here's the relevant piece of my build.gradle

android { defaultConfig { vectorDrawables.useSupportLibrary = true } } dependencies { testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.0.0' compile 'com.android.support:support-vector-drawable:24.0.0' compile 'com.android.support:animated-vector-drawable:24.0.0' compile 'uk.co.chrisjenx:calligraphy:2.2.0' }

这是我的布局文件:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android/apk/res/android" xmlns:app="schemas.android/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" > <ImageView android:id="@+id/iconActive" style="@style/Widget.MyCompany.Button.Icon" app:srcCompat="@drawable/activities" android:layout_marginTop="16dp" android:tint="@color/white" /> </LinearLayout>

如果我只是简单地将ImageView更改为ImageButton,那么它将起作用.按钮也不起作用.

If I simply change the ImageView to an ImageButton it works. Button also does not work.

推荐答案

也许您可以尝试将ImageView更改为 AppCompatImageView .这样就变成了:

Maybe you could try changing ImageView to AppCompatImageView. So it becomes:

<android.support.v7.widget.AppCompatImageView android:id="@+id/iconActive" style="@style/Widget.MyCompany.Button.Icon" app:srcCompat="@drawable/activities" android:layout_marginTop="16dp" android:tint="@color/white" />

更多推荐

app:srcCompat不适用于ImageView

本文发布于:2023-11-27 05:07:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636725.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不适用于   app   srcCompat   ImageView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!