request layout for all view - Android User Interface

Android examples for User Interface:Layout

Description

request layout for all view

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup;

public class Main {

    public static void requestLayoutAllRecurse(View aView) {
        if (aView != null && aView instanceof ViewGroup) {
            int cnt = ((ViewGroup) aView).getChildCount();
            for (int i = 0; i < cnt; i++) {
                View child = ((ViewGroup) aView).getChildAt(i);
                if (child != null && child instanceof ViewGroup) {
                    requestLayoutAllRecurse(child);
                } else if (child != null) {
                    child.requestLayout();
                }/* w  w w.  j  a  v a2s.  c om*/

            }
        }
    }

    public static void requestLayout(View aView) {
        if (aView != null) {
            aView.requestLayout();
        }
    }
}

Related Tutorials