List of usage examples for android.view View getMeasuredHeight
public final int getMeasuredHeight()
From source file:com.brq.wallet.activity.main.WrapContentHeightViewPager.java
/** * Determines the height of this view// w ww . ja v a 2 s . co m * * @param measureSpec * A measureSpec packed into an int * @param view * the base view with already measured height * * @return The height of the view, honoring constraints from measureSpec */ private int measureHeight(int measureSpec, View view) { int result = 0; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); if (specMode == MeasureSpec.EXACTLY) { result = specSize; } else { // set the height from the base view if available if (view != null) { result = view.getMeasuredHeight(); } if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); } } return result; }
From source file:com.culinars.culinars.WrapContentViewPager.java
private int measureViewHeight(View view) { view.measure(getChildMeasureSpec(widthMeasuredSpec, getPaddingLeft() + getPaddingRight(), view.getLayoutParams().width), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); return view.getMeasuredHeight(); }
From source file:be.ugent.zeus.hydra.ui.SwipeyTabs.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthSize = MeasureSpec.getSize(widthMeasureSpec); measureTabs(widthMeasureSpec, heightMeasureSpec); int height = 0; final View v = getChildAt(0); if (v != null) { height = v.getMeasuredHeight(); }// w w w. ja v a 2s . co m setMeasuredDimension(resolveSize(getPaddingLeft() + widthSize + getPaddingRight(), widthMeasureSpec), resolveSize(height + mBottomBarHeight + getPaddingTop() + getPaddingBottom(), heightMeasureSpec)); if (!mInPageScrolled) { updateTabPositions(true); } }
From source file:com.duolingo.open.rtlviewpager.RtlViewPager.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) { int height = 0; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); int h = child.getMeasuredHeight(); if (h > height) { height = h;// ww w .ja va 2 s. co m } } heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:angeloid.dreamnarae.SwipeyTabs.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthSize = MeasureSpec.getSize(widthMeasureSpec); measureTabs(widthMeasureSpec, heightMeasureSpec); int height = 0; final View v = getChildAt(0); if (v != null) { height = v.getMeasuredHeight(); }// w w w.ja v a 2 s . com setMeasuredDimension(resolveSize(getPaddingLeft() + widthSize + getPaddingRight(), widthMeasureSpec), resolveSize(height + mBottomBarHeight + getPaddingTop() + getPaddingBottom(), heightMeasureSpec)); if (mWidth != widthSize) { mWidth = widthSize; updateTabPositions(true); } }
From source file:com.actionbarsherlock.internal.widget.IcsAbsSpinner.java
int getChildHeight(View child) { return child.getMeasuredHeight(); }
From source file:com.chess.genesis.view.SwipeTabs.java
@Override protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { final int widthSize = MeasureSpec.getSize(widthMeasureSpec); measureTabs(widthMeasureSpec, heightMeasureSpec); int height = 0; final View v = getChildAt(0); if (v != null) height = v.getMeasuredHeight(); setMeasuredDimension(resolveSize(getPaddingLeft() + widthSize + getPaddingRight(), widthMeasureSpec), resolveSize(height + mBottomBarHeight + getPaddingTop() + getPaddingBottom(), heightMeasureSpec)); if (mWidth != widthSize) { mWidth = widthSize;//from ww w . j a va2 s. c o m updateTabPositions(true); } }
From source file:android.support.design.internal.BaselineLayout.java
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int count = getChildCount(); int maxWidth = 0; int maxHeight = 0; int maxChildBaseline = -1; int maxChildDescent = -1; int childState = 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; }/* w w w . j ava 2s .com*/ measureChild(child, widthMeasureSpec, heightMeasureSpec); final int baseline = child.getBaseline(); if (baseline != -1) { maxChildBaseline = Math.max(maxChildBaseline, baseline); maxChildDescent = Math.max(maxChildDescent, child.getMeasuredHeight() - baseline); } maxWidth = Math.max(maxWidth, child.getMeasuredWidth()); maxHeight = Math.max(maxHeight, child.getMeasuredHeight()); childState = ViewUtils.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child)); } if (maxChildBaseline != -1) { maxChildDescent = Math.max(maxChildDescent, getPaddingBottom()); maxHeight = Math.max(maxHeight, maxChildBaseline + maxChildDescent); mBaseline = maxChildBaseline; } maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight()); maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth()); setMeasuredDimension(ViewCompat.resolveSizeAndState(maxWidth, widthMeasureSpec, childState), ViewCompat .resolveSizeAndState(maxHeight, heightMeasureSpec, childState << MEASURED_HEIGHT_STATE_SHIFT)); }
From source file:com.moonpi.tapunlock.MainActivity.java
public static void updateListViewHeight(ListView myListView) { ListAdapter myListAdapter = myListView.getAdapter(); if (myListAdapter == null) return;//from ww w.java 2 s. co m // Get listView height int totalHeight = myListView.getPaddingTop() + myListView.getPaddingBottom(); int adapterCount = myListAdapter.getCount(); for (int i = 0; i < adapterCount; i++) { View listItem = myListAdapter.getView(i, null, myListView); if (listItem instanceof ViewGroup) { listItem.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } // Change height of listView ViewGroup.LayoutParams paramsList = myListView.getLayoutParams(); paramsList.height = totalHeight + (myListView.getDividerHeight() * (adapterCount - 1)); myListView.setLayoutParams(paramsList); }
From source file:com.svo.library.widget.RLWebBrowser.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight()); }//from w w w . ja v a2 s . c o m }