How can I check if a view is really visible on screen in Android? -


many examples scrollview, don't have idea relativelayout

in relativelayout, views cover view. can check in xml, how can check java code? use isshown(), willnotdraw(), haswindowfocus(), getlocalvisiblerect(), not working.

case1: container layout on screen

<relativelayout     android:layout_width="match_parent"     android:layout_height="match_parent">      <!--container layout on screen-->     <fragment         android:id="@+id/map_fragment"         android:layout_width="match_parent"         android:layout_height="match_parent"         />      <linearlayout         android:id="@+id/container"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical"         >         <imageview             android:id="@+id/icon"             android:layout_width="50dp"             android:layout_height="50dp"             />         <textview             android:id="@+id/title"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:textsize="18sp"             />         </linearlayout>     </linearlayout> </relativelayout> 

case2: container layout not on screen

<relativelayout     android:layout_width="match_parent"     android:layout_height="match_parent">      <linearlayout         android:id="@+id/container"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical"         >         <imageview             android:id="@+id/icon"             android:layout_width="50dp"             android:layout_height="50dp"             />         <textview             android:id="@+id/title"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:textsize="18sp"             />         </linearlayout>     </linearlayout>      <!--container layout not on screen-->     <fragment         android:id="@+id/map_fragment"         android:layout_width="match_parent"         android:layout_height="match_parent"         /> </relativelayout> 

try using this

   if (myview.isshown()) {         // visible     } else {         // either gone or invisible     } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -