List of usage examples for android.view View getMeasuredHeight
public final int getMeasuredHeight()
From source file:com.appnexus.opensdk.PBImplementation.java
private static Bitmap captureView(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);//from w w w .java 2 s. c om Canvas c = new Canvas(bitmap); view.draw(c); return bitmap; }
From source file:Main.java
public static int getHeight(View view) { int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); view.measure(w, h);//from w w w .ja v a 2 s . c o m return view.getMeasuredHeight(); }
From source file:Main.java
static Rect getViewAbsRect(View view, int parentX, int parentY) { int[] loc = new int[2]; view.getLocationInWindow(loc);//from w w w . j a v a 2s . co m Rect rect = new Rect(); rect.set(loc[0], loc[1], loc[0] + view.getMeasuredWidth(), loc[1] + view.getMeasuredHeight()); rect.offset(-parentX, -parentY); return rect; }
From source file:Main.java
public static int getHeight(View view) { int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); view.measure(w, h);/*from www .jav a 2s. com*/ return (view.getMeasuredHeight()); }
From source file:Main.java
public static Bitmap convertViewToBitmap(View view) { view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.buildDrawingCache();//from w w w .ja va2s. com Bitmap bitmap = view.getDrawingCache(); return bitmap; }
From source file:Main.java
public static Bitmap getBitmapFromView(View paramView) { paramView.destroyDrawingCache();// ww w . ja v a 2 s . c o m paramView.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0)); paramView.layout(0, 0, paramView.getMeasuredWidth(), paramView.getMeasuredHeight()); paramView.setDrawingCacheEnabled(true); return paramView.getDrawingCache(true); }
From source file:Main.java
public static int getViewHeight(View view) { int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); view.measure(w, h);//from w ww . j ava 2 s .co m int height = view.getMeasuredHeight(); return height; }
From source file:Main.java
public static int getAbsListViewHeight(AbsListView absListView, int lineNumber, int verticalSpace) { int totalHeight = 0; int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); absListView.measure(w, h);// ww w . jav a 2s . c om ListAdapter mListAdapter = absListView.getAdapter(); if (mListAdapter == null) { return totalHeight; } int count = mListAdapter.getCount(); if (absListView instanceof ListView) { for (int i = 0; i < count; i++) { View listItem = mListAdapter.getView(i, null, absListView); listItem.measure(w, h); totalHeight += listItem.getMeasuredHeight(); } if (count == 0) { totalHeight = verticalSpace; } else { totalHeight = totalHeight + (((ListView) absListView).getDividerHeight() * (count - 1)); } } else if (absListView instanceof GridView) { int remain = count % lineNumber; if (remain > 0) { remain = 1; } if (mListAdapter.getCount() == 0) { totalHeight = verticalSpace; } else { View listItem = mListAdapter.getView(0, null, absListView); listItem.measure(w, h); int line = count / lineNumber + remain; totalHeight = line * listItem.getMeasuredHeight() + (line - 1) * verticalSpace; } } return totalHeight; }
From source file:Main.java
public static int getMeasuredHeight(View v) { int leftw = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int lefth = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); v.measure(leftw, lefth);/* ww w . j a v a 2 s .co m*/ return v.getMeasuredHeight(); }
From source file:Main.java
public static void setAbsListViewHeight(AbsListView absListView, int lineNumber, int verticalSpace) { if (lineNumber == 0) { return;/*from www . j a v a 2s . com*/ } int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); ListAdapter mListAdapter = absListView.getAdapter(); if (mListAdapter == null) { return; } int totalHeight = 0; int count = mListAdapter.getCount(); ViewGroup.LayoutParams params = absListView.getLayoutParams(); if (absListView instanceof ListView) { for (int i = 0; i < count; i++) { View listItem = mListAdapter.getView(i, null, absListView); listItem.measure(w, h); totalHeight += listItem.getMeasuredHeight(); } if (count == 0) { params.height = verticalSpace; } else { params.height = totalHeight + (((ListView) absListView).getDividerHeight() * (count - 1)); } } else if (absListView instanceof GridView) { int remain = count % lineNumber; if (remain > 0) { remain = 1; } if (mListAdapter.getCount() == 0) { params.height = verticalSpace; } else { View listItem = mListAdapter.getView(0, null, absListView); listItem.measure(w, h); int line = count / lineNumber + remain; params.height = line * listItem.getMeasuredHeight() + (line + 1) * verticalSpace; } } ((MarginLayoutParams) params).setMargins(0, 0, 0, 0); absListView.setLayoutParams(params); }