Android - Get the visible area of a view?

前端 未结 3 866
忘掉有多难
忘掉有多难 2021-01-01 11:58

Suppose I have an Android View that is being partially masked by another View. For instance, imagine that the masking view has a transparent recta

相关标签:
3条回答
  • 2021-01-01 12:20

    I have used getWindowVisibleDisplayFrame method to determine if view is partially visible or not to determine if a soft keyboard is open. You can try it out.

    Rect r = new Rect();
    // r will be populated with the coordinates of     your view
    // that area still visible.
    rootView.getWindowVisibleDisplayFrame(r);
    
    0 讨论(0)
  • 2021-01-01 12:33

    Does this not work: http://developer.android.com/reference/android/view/View.html#getDrawingRect(android.graphics.Rect)

    The documentation says that it does what you want.

    0 讨论(0)
  • 2021-01-01 12:38

    This is pretty late to the game, but I suspect that getGlobalVisibleRect does what you want.

    0 讨论(0)
提交回复
热议问题