Injury
Injury

Reputation: 143

Check a view is visible to the screen

I use ZoomableImageView at Android imageView Zoom-in and Zoom-Out (See Nicolas Tyler's post)

I am using FrameLayout for overlap-view techniques. I want the ball (ImageView with id ball) to always overlap the (background) map (ZoomableImageView with id map).

The layout is like:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <mypackage.ZoomableImageView
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="matrix"
        android:src="@raw/gamemap"
        />
    <ImageView
        android:id="@+id/ball"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@raw/ball"
        />
</FrameLayout>

The ball is "attach" ("map to") to a (visible) point (for instance: PointF) on the gamemap. Like a map-application, when I zoom the background (gamemap), the ball needs to be automatically moved relative to the gamemap. So the ball would be visible or invisible to the screen when zooming.

I want to implement as I said. I want to check the ball is visible or invisible to the screen. What should I do?

Upvotes: 0

Views: 1149

Answers (2)

Soufiane Azeroual
Soufiane Azeroual

Reputation: 143

Or you could simply use

View.isShown()

Upvotes: 0

Srishti Roy
Srishti Roy

Reputation: 576

You can check the visibility of any view like this.

if(tvEndDate.getVisibility()==View.VISIBLE)
{

// do your stuff
}

Upvotes: 2

Related Questions