你如何确定一个TextView的背景颜色? [英] How do you determine the background color of a TextView?

查看:152
本文介绍了你如何确定一个TextView的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的测试中,我想确保视图(而不是ImageView的),有一定的背景颜色。我怎么能与有问题的视图交互做到这一点直接?

In my tests I want to make sure that a View (not an ImageView) has a certain background color. How could I do this directly by interacting with the View in question?

这种观点的背景是不是一个可绘制。它在XML中设置或它是使用设置 view.setBackgroundColor(...)

The background of this view is not a Drawable. It was either set in the XML or it was set using view.setBackgroundColor(...).

推荐答案

您可以使用此获取的TextView的背景颜色。

you can use this for getting the background color of textview..

yourTextView.getBackgroundResource(R.color.white);

/值的文件夹


<color name="white">#ffffffff</color>

这篇关于你如何确定一个TextView的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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