I am writing a test UI example (using ActivityUnitTestCase) and would like to check if the view of the View subclass is currently visible to the user. I found the View # isShown () method , which claims to do just that - checking the field of view of this element and all its parents - but for some reason it always returns false for all elements. I will be grateful for the help. If this simplifies, I can insert the code.
In addition, I found ViewAsserts # assertOnScreen (View start, View view) , but it also does not work correctly - it always returns true. Perhaps I called it wrong: assertOnScreen (viewImTesting.getRootView (), viewImTesting)?
Thanks, Jan
I found a reasonable workaround: simply by checking View # getVisibility () against View # VISIBLE , VIEW # INVISIBLE or VIEW # GONE .
This probably does not work when, for example, the parent view is not displayed, but it has the visibility set to VISIBLE, but in most cases this should be enough.
Try using
final View origin = activityImTesting.getWindow().getDecorView(); android.test.ViewAsserts.assertOnScreen(origin, viewImTesting);
, ? @dtmilano Android-, , "".
visibility = gone , , , , . , - x y, 0.
ViewAsserts.java, assertOnScreen() y , , 0, .
: assertOnScreen, , , , , , , .
, ( )!
Source: https://habr.com/ru/post/1790470/More articles:Classic View / Mobile View Switch? - redirectExample list of flags in mvc3 Razor, - c #java JIT - what kind of optimizations are possible? - javaNHibernate PreSelect? - c #NSNumberFormatter Error from Apple Documentation "Data Formatting Guide" - iosMany InfoWindow markers in Google Maps v3 - google-maps-api-3Given the HtmlUnit HtmlPage object, how do I get the URI of my document? - htmlunitthe unmanaged dependency of a dll dll on C ++ is not copied to the application folder, and another managed dll is visual-studioAdding HTTPHandler using SPWebConfigModification - sharepointWindsor Castle - Injection of Value - c #All Articles