/**     * 判断view是否被隐藏(如scrollview中被滑动到不可见位置的view)     */    public static boolean isViewCovered(final View view) {        View currentView = view;        Rect currentViewRect = new Rect();        boolean partVisible = currentView.getGlobalVisibleRect(currentViewRect);        boolean totalHeightVisible = (currentViewRect.bottom - currentViewRect.top) >= currentView.getMeasuredHeight();        boolean totalWidthVisible = (currentViewRect.right - currentViewRect.left) >= currentView.getMeasuredWidth();        boolean totalViewVisible = partVisible && totalHeightVisible && totalWidthVisible;        if (!totalViewVisible) // if any part of the view is clipped by any of its parents,return true            return true;        while (currentView.getParent() instanceof ViewGroup) {            ViewGroup currentParent = (ViewGroup) currentView.getParent();            if (currentParent.getVisibility() != View.VISIBLE) // if the parent of view is not visible,return true                return true;            int start = indexOfViewInParent(currentView, currentParent);            for (int i = start + 1; i < currentParent.getChildCount(); i++) {                Rect viewRect = new Rect();                view.getGlobalVisibleRect(viewRect);                View otherView = currentParent.getChildAt(i);                Rect otherViewRect = new Rect();                otherView.getGlobalVisibleRect(otherViewRect);                if (Rect.intersects(viewRect, otherViewRect)) // if view intersects its older brother(covered),return                    // true                    return true;            }            currentView = currentParent;        }        return false;    }

更多相关文章

  1. SlidingMenu和ActionBarSherlock结合做出出色的App布局,Facebook
  2. linearLayout 和 relativeLayout的属性区别
  3. Android解决父控件拦截子控件手势滑动事件的问题
  4. 调出软键盘 挤掉标题栏咋办
  5. 固定屏幕显示模式 ScreenOrientation
  6. ListView美化
  7. Android横向智能刷新框架-SmartRefreshHorizontal+ScrollView 实
  8. Android全屏(包含3种隐藏顶部状态栏及标题栏和一种隐藏Android(安
  9. android 仿写 screen lock

随机推荐

  1. Using WebViews and JavaScript
  2. 【转】Android --权限大全
  3. Android之离线词典
  4. android 模拟器使用指导
  5. Android SDK Manager安装过程
  6. Android SDK 源码
  7. Android(安卓)String format
  8. Android_Servcie_后台服务总结笔记
  9. 设置listview中的item的颜色
  10. 学习电子书和视频大全