Android examples for User Interface:View Child
get Children Sum Height
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { public static int getChildsSumHeight(View parent) { int height = 0; if (parent instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) parent; for (int j = 0; j < viewGroup.getChildCount(); j++) { View view = viewGroup.getChildAt(j); height += view.getHeight(); if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view .getLayoutParams(); height += params.bottomMargin + params.topMargin; }/*from w w w . ja v a 2 s. co m*/ } } else { height = parent.getHeight(); } return height; } }