List of usage examples for android.view View layout
@SuppressWarnings({ "unchecked" }) public void layout(int l, int t, int r, int b)
This is the second phase of the layout mechanism.
From source file:com.facebook.litho.LithoView.java
private static void performLayoutOnChildrenIfNecessary(ComponentHost host) { for (int i = 0, count = host.getChildCount(); i < count; i++) { final View child = host.getChildAt(i); if (child.isLayoutRequested()) { // The hosting view doesn't allow children to change sizes dynamically as // this would conflict with the component's own layout calculations. child.measure(MeasureSpec.makeMeasureSpec(child.getWidth(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getHeight(), MeasureSpec.EXACTLY)); child.layout(child.getLeft(), child.getTop(), child.getRight(), child.getBottom()); }// w w w .j a va2 s. co m if (child instanceof ComponentHost) { performLayoutOnChildrenIfNecessary((ComponentHost) child); } } }
From source file:Main.java
public static Bitmap convertViewToBitmap(View comBitmap, int width, int height) { Bitmap bitmap = null;/*w w w. jav a2 s .co m*/ if (comBitmap != null) { comBitmap.clearFocus(); comBitmap.setPressed(false); boolean willNotCache = comBitmap.willNotCacheDrawing(); comBitmap.setWillNotCacheDrawing(false); // Reset the drawing cache background color to fully transparent // for the duration of this operation int color = comBitmap.getDrawingCacheBackgroundColor(); comBitmap.setDrawingCacheBackgroundColor(0); float alpha = comBitmap.getAlpha(); comBitmap.setAlpha(1.0f); if (color != 0) { comBitmap.destroyDrawingCache(); } int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY); comBitmap.measure(widthSpec, heightSpec); comBitmap.layout(0, 0, width, height); comBitmap.buildDrawingCache(); Bitmap cacheBitmap = comBitmap.getDrawingCache(); if (cacheBitmap == null) { Log.e("view.ProcessImageToBlur", "failed getViewBitmap(" + comBitmap + ")", new RuntimeException()); return null; } bitmap = Bitmap.createBitmap(cacheBitmap); // Restore the view comBitmap.setAlpha(alpha); comBitmap.destroyDrawingCache(); comBitmap.setWillNotCacheDrawing(willNotCache); comBitmap.setDrawingCacheBackgroundColor(color); } return bitmap; }
From source file:com.asc_ii.bangnote.bigbang.BigBangActionBar.java
private void layoutSubView(View view, int l, int t) { view.layout(l, t, view.getMeasuredWidth() + l, view.getMeasuredHeight() + t); }
From source file:com.cocarechina.pullrefreshview.layout.PullRefreshLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); int height = getHeight(); if (mHeader != null) { View mHeaderView = (View) mHeader; mHeaderView.layout(mHeaderView.getLeft(), -mHeaderView.getMeasuredHeight(), mHeaderView.getRight(), 0); }//from w w w .j a v a2 s . c om if (mFooter != null) { View mFooterView = (View) mFooter; mFooterView.layout(mFooterView.getLeft(), height, mFooterView.getRight(), height + mFooterView.getMeasuredHeight()); } }
From source file:de.vanita5.twittnuker.view.ComposeSelectAccountButton.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { for (int i = 0, j = getChildCount(); i < j; i++) { final View child = getChildAt(i); child.layout(getPaddingLeft(), getPaddingTop(), r - l - getPaddingRight(), b - t - getPaddingBottom()); }/*w w w .j av a 2s .c o m*/ }
From source file:com.manning.androidhacks.hack003.view.CascadeLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); LayoutParams lp = (LayoutParams) child.getLayoutParams(); child.layout(lp.x, lp.y, lp.x + child.getMeasuredWidth(), lp.y + child.getMeasuredHeight()); }/*from w w w .j ava 2s . c o m*/ }
From source file:org.cyanogenmod.theme.util.ChooserDetailLinearLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); // Place the page indicator above the drawer handle View pageIndicator = getChildAt(PAGE_INDICATOR_INDEX); int top = getChildAt(DRAWER_HANDLE_INDEX).getTop(); int height = pageIndicator.getMeasuredHeight(); pageIndicator.layout(l, top - height, r, top); }
From source file:com.andremion.heroes.ui.util.PagerSharedElementCallback.java
private void forceSharedElementLayout(View view) { int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(view.getHeight(), View.MeasureSpec.EXACTLY); view.measure(widthSpec, heightSpec); view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); }
From source file:org.mariotaku.twidere.view.CardMediaContainer.java
private void layoutGridMedia(int childCount, int columnCount, int horizontalSpacing, int verticalSpacing, int[] childIndices) { final int initialLeft = getPaddingLeft(); int left = initialLeft, top = getPaddingTop(); for (int i = 0; i < childCount; i++) { final int colIdx = i % columnCount; final View child = getChildAt(childIndices[i]); child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight()); if (colIdx == columnCount - 1) { // Last item in this row, set top of next row to last view bottom + verticalSpacing top = child.getBottom() + verticalSpacing; // And reset left to initial left left = initialLeft;//from w ww .j a v a2 s. c om } else { // The left of next item is right + horizontalSpacing of previous item left = child.getRight() + horizontalSpacing; } } }
From source file:com.arthurpitman.common.SlidingPanel.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int width = getMeasuredWidth(); viewHeight = getMeasuredHeight();/*from w ww . ja v a 2s .c o m*/ View view1 = getChildAt(0); if (view1 != null) { collapsedHeight = view1.getMeasuredHeight(); view1.layout(0, viewHeight - collapsedHeight, width, viewHeight); } View view2 = getChildAt(1); if (view2 != null) { view2.layout(0, viewHeight, width, viewHeight * 2); } }