Java Code Examples for android.view.ViewGroup#isInLayout()

The following examples show how to use android.view.ViewGroup#isInLayout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuaViewUtil.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
/**
 * remove a view
 *
 * @param parent
 * @param view
 */
public static void removeView(ViewGroup parent, View view) {
    //这里不使用post来做,这样代码更可控,而是改为将refresh下拉动作延后一帧处理,见@link
    //这里调用removeViewInLayout方法,可以在onLayout的时候调用,否则会产生问题
    if (parent != null && view != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            if (parent.isInLayout()) {
                parent.removeViewInLayout(view);
            } else {
                parent.removeView(view);
            }
        } else {
            parent.removeView(view);
        }
    }
}
 
Example 2
Source File: LuaViewUtil.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * remove all views
 *
 * @param viewGroup
 */
public static void removeAllViews(ViewGroup viewGroup) {
    if (viewGroup != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            if (viewGroup.isInLayout()) {
                viewGroup.removeAllViewsInLayout();
            } else {
                viewGroup.removeAllViews();
            }
        } else {
            viewGroup.removeAllViews();
        }
    }
}