我的Android应用程序中有一个文本字段(EditView),如果其值无效或为空,它将更改颜色(边界)。在这种情况下,label(TextView)也会更改其颜色。
当我尝试使用使用TextView时query
,我看到以下内容:
[0] {
"id" => "field_lable",
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.TextView",
"text" => "Name",
"rect" => {
"center_y" => 198.5,
"center_x" => 51.0,
"height" => 27,
"y" => 185,
"width" => 82,
"x" => 10
},
"description" => "android.widget.TextView@a28btb00"
}
如果我需要获取文字,可以使用 query("TextView id:'field_label'", :text)
葫芦中有什么方法可以获取TextView的颜色吗?
不幸的是,这在Android中是不可能的。
在Android中,Views
(以及TextView
)几乎可以具有任何背景作为背景,而不仅仅是颜色(位图,形状,渐变颜色等)。因此,无法获取视图的背景色(不存储背景色)。
这不是Calabash的限制,而是Android系统。您可以获取Android视图的任何属性(如果可访问)。
您可以在TextView上查询以下颜色(无背景):
:currentTextColor
:hintTextColor
:highlightColor
:shadowColor
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句