android - 检查 View 在屏幕上是否可见

标签 android algorithm

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

我将 FrameLayout 用于重叠 View 技术。我希望球(带有 id 球的 ImageView)始终与(背景) map (带有 id map 的 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>

球“附加”(“映射到”)到游戏 map 上的(可见)点(例如:PointF)。就像 map 应用程序一样,当我缩放背景(游戏 map )时,球需要相对于游戏 map 自动移动。因此,在缩放时,球在屏幕上是可见的还是不可见的。

我想按照我说的去做。我想检查球在屏幕上是可见的还是不可见的。我该怎么办?

最佳答案

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

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

// do your stuff
}

关于android - 检查 View 在屏幕上是否可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30391100/

相关文章:

Android Intent 语法

java - SwipeRefreshLayout 在每次刷新后减小我的 View 的大小

java - 在 Activity 之间传递 'data source'

algorithm - 具有唯一值的排序字节数组 - 最大可能压缩

android - 具有 ConstraintLayout 对话框宽度的 AppCompatDialogFragment

android - 如何查找 Android 设备是否具有音频功能?

python - 带限制条件的长度为 L 的子序列的最大和

algorithm - A-star是否保证给出二维网格中的最短路径

c++ - 运行反向字符串程序时导致停止工作

performance - 一阶公式中变量的有效重命名