List of usage examples for android.view Gravity LEFT
int LEFT
To view the source code for android.view Gravity LEFT.
Click Source Link
From source file:com.hb.hkm.slidinglayer.SlidLayer.java
private void adjustLayoutParams() { ViewGroup.LayoutParams baseParams = getLayoutParams(); if (baseParams instanceof LayoutParams) { LayoutParams layoutParams = (LayoutParams) baseParams; switch (mScreenSide) { case STICK_TO_BOTTOM: layoutParams.gravity = Gravity.BOTTOM; break; case STICK_TO_LEFT: layoutParams.gravity = Gravity.LEFT; break; case STICK_TO_RIGHT: layoutParams.gravity = Gravity.RIGHT; break; case STICK_TO_TOP: layoutParams.gravity = Gravity.TOP; break; }/* ww w .j a v a2 s . co m*/ setLayoutParams(baseParams); } else if (baseParams instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) baseParams; switch (mScreenSide) { case STICK_TO_BOTTOM: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); break; case STICK_TO_LEFT: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); break; case STICK_TO_RIGHT: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); break; case STICK_TO_TOP: layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); break; } } }
From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java
/** * Close the specified drawer view by animating it into view. * * @param drawerView Drawer view to close *///from w w w . ja v a 2 s. c om public void closeDrawer(View drawerView) { if (!isDrawerView(drawerView)) { throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer"); } if (mFirstLayout) { final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); lp.onScreen = 0.f; lp.knownOpen = false; } else { if (checkDrawerViewGravity(drawerView, Gravity.LEFT)) { mLeftDragger.smoothSlideViewTo(drawerView, -drawerView.getWidth(), drawerView.getTop()); } else { mRightDragger.smoothSlideViewTo(drawerView, getWidth(), drawerView.getTop()); } } invalidate(); }
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
@Override public void onClickLeftIcon() { if (null == mSearchBar) { return;//from www .j a va 2s .c om } if (mSearchBar.getState() == SearchBar.STATE_NORMAL) { toggleDrawer(Gravity.LEFT); } else { setState(STATE_NORMAL); } }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
/** * Given the desired width and height of the ring and the allocated width and height, compute * how much we need to scale the ring.//from w w w .j av a2s .co m */ private float computeScaleFactor(int desiredWidth, int desiredHeight, int actualWidth, int actualHeight) { // Return unity if scaling is not allowed. if (!mAllowScaling) return 1f; final int layoutDirection = getLayoutDirection(); final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection); float scaleX = 1f; float scaleY = 1f; // We use the gravity as a cue for whether we want to scale on a particular axis. // We only scale to fit horizontally if we're not pinned to the left or right. Likewise, // we only scale to fit vertically if we're not pinned to the top or bottom. In these // cases, we want the ring to hang off the side or top/bottom, respectively. switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.LEFT: case Gravity.RIGHT: break; case Gravity.CENTER_HORIZONTAL: default: if (desiredWidth > actualWidth) { scaleX = (1f * actualWidth - mMaxTargetWidth) / (desiredWidth - mMaxTargetWidth); } break; } switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: case Gravity.BOTTOM: break; case Gravity.CENTER_VERTICAL: default: if (desiredHeight > actualHeight) { scaleY = (1f * actualHeight - mMaxTargetHeight) / (desiredHeight - mMaxTargetHeight); } break; } return Math.min(scaleX, scaleY); }
From source file:com.chenglong.muscle.ui.LazyViewPager.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;//from w w w .j a v a 2 s. co m populate(); mInLayout = false; final int count = getChildCount(); int width = r - l; int height = b - t; int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); final int scrollX = getScrollX(); int decorCount = 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); ItemInfo ii; int childLeft = 0; int childTop = 0; if (lp.isDecor) { final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (hgrav) { default: childLeft = paddingLeft; break; case Gravity.LEFT: childLeft = paddingLeft; paddingLeft += child.getMeasuredWidth(); break; case Gravity.CENTER_HORIZONTAL: childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft); break; case Gravity.RIGHT: childLeft = width - paddingRight - child.getMeasuredWidth(); paddingRight += child.getMeasuredWidth(); break; } switch (vgrav) { default: childTop = paddingTop; break; case Gravity.TOP: childTop = paddingTop; paddingTop += child.getMeasuredHeight(); break; case Gravity.CENTER_VERTICAL: childTop = Math.max((height - child.getMeasuredHeight()) / 2, paddingTop); break; case Gravity.BOTTOM: childTop = height - paddingBottom - child.getMeasuredHeight(); paddingBottom += child.getMeasuredHeight(); break; } childLeft += scrollX; decorCount++; child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } else if ((ii = infoForChild(child)) != null) { int loff = (width + mPageMargin) * ii.position; childLeft = paddingLeft + loff; childTop = paddingTop; if (DEBUG) Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight()); child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } } mTopPageBounds = paddingTop; mBottomPageBounds = height - paddingBottom; mDecorChildCount = decorCount; mFirstLayout = false; }
From source file:com.ferg.awfulapp.widget.AwfulViewPager.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;/* w w w . j a va 2 s . c o m*/ populate(); mInLayout = false; final int count = getChildCount(); int width = r - l; int height = b - t; int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); final int scrollX = getScrollX(); int decorCount = 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); ItemInfo ii; int childLeft = 0; int childTop = 0; if (lp.isDecor) { final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (hgrav) { default: childLeft = paddingLeft; break; case Gravity.LEFT: childLeft = paddingLeft; paddingLeft += child.getMeasuredWidth(); break; case Gravity.CENTER_HORIZONTAL: childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft); break; case Gravity.RIGHT: childLeft = width - paddingRight - child.getMeasuredWidth(); paddingRight += child.getMeasuredWidth(); break; } switch (vgrav) { default: childTop = paddingTop; break; case Gravity.TOP: childTop = paddingTop; paddingTop += child.getMeasuredHeight(); break; case Gravity.CENTER_VERTICAL: childTop = Math.max((height - child.getMeasuredHeight()) / 2, paddingTop); break; case Gravity.BOTTOM: childTop = height - paddingBottom - child.getMeasuredHeight(); paddingBottom += child.getMeasuredHeight(); break; } childLeft += scrollX; decorCount++; child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } else if ((ii = infoForChild(child)) != null) { int loff = (width + mPageMargin) * ii.position; childLeft = paddingLeft + loff; childTop = paddingTop; // if (DEBUG) Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object // + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth() // + "x" + child.getMeasuredHeight()); child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } } mTopPageBounds = paddingTop; mBottomPageBounds = height - paddingBottom; mDecorChildCount = decorCount; mFirstLayout = false; }
From source file:com.aidy.bottomdrawerlayout.DrawerLayout.java
/** * Open the specified drawer view by animating it into view. * /*w ww . j a v a2s .com*/ * @param drawerView * Drawer view to open */ public void openDrawer(View drawerView) { Log.i(TAG, "openDrawer() --view"); if (!isDrawerView(drawerView)) { throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer"); } if (mFirstLayout) { final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); lp.onScreen = 1.f; lp.knownOpen = true; } else { if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT)) { mLeftDragger.smoothSlideViewTo(drawerView, 0, drawerView.getTop()); } else { mRightDragger.smoothSlideViewTo(drawerView, getWidth() - drawerView.getWidth(), drawerView.getTop()); } } invalidate(); }
From source file:beichen.douban.ui.view.LazyViewPager.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;//from ww w. j a va 2 s .c o m populate(); mInLayout = false; final int count = getChildCount(); int width = r - l; int height = b - t; int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); final int scrollX = getScrollX(); int decorCount = 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); ItemInfo ii; int childLeft = 0; int childTop = 0; if (lp.isDecor) { final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (hgrav) { default: childLeft = paddingLeft; break; case Gravity.LEFT: childLeft = paddingLeft; paddingLeft += child.getMeasuredWidth(); break; case Gravity.CENTER_HORIZONTAL: childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft); break; case Gravity.RIGHT: childLeft = width - paddingRight - child.getMeasuredWidth(); paddingRight += child.getMeasuredWidth(); break; } switch (vgrav) { default: childTop = paddingTop; break; case Gravity.TOP: childTop = paddingTop; paddingTop += child.getMeasuredHeight(); break; case Gravity.CENTER_VERTICAL: childTop = Math.max((height - child.getMeasuredHeight()) / 2, paddingTop); break; case Gravity.BOTTOM: childTop = height - paddingBottom - child.getMeasuredHeight(); paddingBottom += child.getMeasuredHeight(); break; } childLeft += scrollX; decorCount++; child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } else if ((ii = infoForChild(child)) != null) { int loff = (width + mPageMargin) * ii.position; childLeft = paddingLeft + loff; childTop = paddingTop; if (DEBUG) Log.v(TAG, "Positioning #" + i + " " + child + " f=" + ii.object + ":" + childLeft + "," + childTop + " " + child.getMeasuredWidth() + "x" + child.getMeasuredHeight()); child.layout(childLeft, childTop, childLeft + child.getMeasuredWidth(), childTop + child.getMeasuredHeight()); } } } mTopPageBounds = paddingTop; mBottomPageBounds = height - paddingBottom; mDecorChildCount = decorCount; mFirstLayout = false; }
From source file:administrator.example.com.myscrollview.VerticalViewPager.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // For simple implementation, or internal size is always 0. // We depend on the container to specify the layout size of // our view. We can't really know what it is since we will be // adding and removing different arbitrary views and do not // want the layout to change as this happens. setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec)); // Children are just made to fill our space. int childWidthSize = getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); int childHeightSize = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); /*//from w w w. ja va 2 s. c o m * Make sure all children have been properly measured. Decor views first. * Right now we cheat and make this less complicated by assuming decor * views won't intersect. We will pin to edges based on gravity. */ int size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp != null && lp.isDecor) { final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; Log.d(TAG, "gravity: " + lp.gravity + " hgrav: " + hgrav + " vgrav: " + vgrav); int widthMode = MeasureSpec.AT_MOST; int heightMode = MeasureSpec.AT_MOST; boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM; boolean consumeHorizontal = hgrav == Gravity.LEFT || hgrav == Gravity.RIGHT; if (consumeVertical) { widthMode = MeasureSpec.EXACTLY; } else if (consumeHorizontal) { heightMode = MeasureSpec.EXACTLY; } /* end of if */ final int widthSpec = MeasureSpec.makeMeasureSpec(childWidthSize, widthMode); final int heightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, heightMode); child.measure(widthSpec, heightSpec); if (consumeVertical) { childHeightSize -= child.getMeasuredHeight(); } else if (consumeHorizontal) { childWidthSize -= child.getMeasuredWidth(); } /* end of if */ } /* end of if */ } /* end of if */ } /* end of for */ mChildWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY); mChildHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY); // Make sure we have created all fragments that we need to have shown. mInLayout = true; populate(); mInLayout = false; // Page views next. size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { if (DEBUG) Log.v(TAG, "Measuring #" + i + " " + child + ": " + mChildWidthMeasureSpec); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); if (lp == null || !lp.isDecor) { child.measure(mChildWidthMeasureSpec, mChildHeightMeasureSpec); } /* end of if */ } /* end of if */ } /* end of for */ }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
/** * When a file can't be opened//from w ww .ja va 2 s . co m * Invoked by the EditorFragment * * @param event The event called */ void cannotOpenFile() { // mDrawerLayout.openDrawer(Gravity.LEFT); // getSupportActionBar().setTitle(getString(R.string.nome_app_turbo_editor)); // supportInvalidateOptionsMenu(); // Replace fragment hideTextEditor(); }