【问题标题】:Check a view is visible to the screen检查视图是否对屏幕可见
【发布时间】:2016-09-06 20:58:10
【问题描述】:

我在Android imageView Zoom-in and Zoom-Out 使用 ZoomableImageView(参见 Nicolas Tyler 的帖子)

我将 FrameLayout 用于重叠视图技术。我希望球(带有 id 球的 ImageView)始终与(背景)地图(带有 id 地图的 ZoomableImageView)重叠。

布局是这样的:

<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>

球“附着”(“映射到”)到游戏地图上的(可见)点(例如:PointF)。像地图应用程序一样,当我缩放背景(游戏地图)时,球需要相对于游戏地图自动移动。所以缩放时球对屏幕可见或不可见。

我想按照我说的执行。我想检查球对屏幕可见或不可见。我该怎么办?

【问题讨论】:

    标签: android algorithm


    【解决方案1】:

    您可以像这样检查任何视图的可见性。

    if(tvEndDate.getVisibility()==View.VISIBLE)
    {
    
    // do your stuff
    }
    

    【讨论】:

      【解决方案2】:

      或者你可以简单地使用

      View.isShown()
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-29
        • 2011-07-18
        • 2014-12-15
        • 1970-01-01
        • 2018-07-06
        相关资源
        最近更新 更多