Android ViewGroup Set disableView(ViewGroup rootView, float alpha)

Here you can find the source of disableView(ViewGroup rootView, float alpha)

Description

Disable all the childs of the selected root view

License

Open Source License

Parameter

Parameter Description
rootView View to iterate in order to disable all its childs
alpha Alpha to set to disabled elements

Declaration

public static void disableView(ViewGroup rootView, float alpha) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.os.Build;

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

public class Main {
    /**/*  w w w  .  j a  v  a  2s. com*/
     * Disable all the childs of the selected root view
     *
     * @param rootView
     *    View to iterate in order to disable all its childs
     * @param alpha
     *    Alpha to set to disabled elements
     */
    public static void disableView(ViewGroup rootView, float alpha) {
        int count = rootView.getChildCount();
        View v;
        //Go over the child list of the view and disable all
        for (int i = 0; i < count; i++) {
            v = rootView.getChildAt(i);
            if (v != null) {
                if (v instanceof ViewGroup)
                    disableView((ViewGroup) v, alpha);
                if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO)
                    v.setAlpha(alpha);
                v.setEnabled(false);
            }
        }
    }
}

Related

  1. layoutChildAbsoluteCenter(ViewGroup parent, View child, int tWidth, int tHeight)
  2. setReadingFontOnChildren(ViewGroup container)
  3. setSelected(ViewGroup viewGroup, boolean selected)