在Android的TextView中将Color设置为drawableTop图像 [英] Set Color to the drawableTop image inside a TextView in android

查看:374
本文介绍了在Android的TextView中将Color设置为drawableTop图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有drawableTop的textView,但是图像是黑色的,我想将颜色更改为白色,有没有一种方法可以做到而无需创建单独的imageView和TextView.

I have a textView with drawableTop, but the image is in black color and i would like to change the color to white.Is there a way to do it without creating seperate imageView and TextView.

下面是供参考的xml.

Below is the xml for reference.

<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:gravity="center_horizontal|bottom"
    android:drawableTop="@drawable/ic_add_room"
    android:text="More"/>

推荐答案

使用着色 android:drawableTint 更改颜色.提示:

Use Tint android:drawableTint to change color. Exmp :

<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="48dp"
    android:drawableTint="#fff"
    android:layout_height="48dp"
    android:gravity="center_horizontal|bottom"
    android:drawableTop="@drawable/ic_add_room"
    android:text="More"/>

这篇关于在Android的TextView中将Color设置为drawableTop图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆