Android examples for User Interface:View
is View Attached To Decoration View
//package com.java2s; import android.app.Activity; import android.view.View; import android.view.ViewParent; public class Main { public static boolean isViewAttachedToDecorView(View view) { if (!(view.getContext() instanceof Activity)) { return true; }//from w w w . j a v a2 s . c om View decorView = ((Activity) view.getContext()).getWindow() .getDecorView(); if (view == decorView) { return true; } if (view.getWindowToken() != null && view.getWindowToken() != decorView.getWindowToken()) { // The view is not in the same window with activity. It's probably in a Dialog. return true; } ViewParent parent = view.getParent(); while (parent != null) { if (parent == decorView) { return true; } parent = parent.getParent(); } return false; } }