我的Android应用中有一个文本字段(EditView),如果它的值无效或为空,它会更改颜色(边框)。在这种情况下,标签(TextView)也会改变颜色。
当我尝试使用query
获取TextView时,我看到以下内容:
[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)
在calabash中有没有办法获得TextView的颜色?
答案 0 :(得分:3)
不幸的是,这在Android中无法实现。
在Android中,Views
(也是TextView
)几乎可以作为背景而不仅仅是颜色(位图,形状,渐变颜色等)。因此,无法获得视图的背景颜色(它没有存储)。
这不是Calabash的限制,而是Android系统。如果可以访问,您可以获取Android视图的任何属性。
您可以在TextView上查询以下颜色(没有任何背景):
:currentTextColor
:hintTextColor
:highlightColor
:shadowColor