试试View treeobserver方法。
main_layout.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout()
{
Rect r = new Rect();
// r will be populated with the coordinates of your view
// that area still visible.
main_layout.getWindowVisibleDisplayFrame(r);
int heightDiff = main_layout.getRootView().getHeight()-(r.bottom -r.top);
}
});
Run Code Online (Sandbox Code Playgroud)
将main_layout替换为所需的View对象。希望能有所帮助。
| 归档时间: |
|
| 查看次数: |
3509 次 |
| 最近记录: |