List of usage examples for android.view Gravity RIGHT
int RIGHT
To view the source code for android.view Gravity RIGHT.
Click Source Link
From source file:android.support.designox.widget.CollapsingTextHelper.java
private void calculateBaseOffsets() { final float currentTextSize = mCurrentTextSize; // We then calculate the collapsed text size, using the same logic calculateUsingTextSize(mCollapsedTextSize); float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mCollapsedDrawY = mCollapsedBounds.bottom; break;/*from w w w. j a va 2 s.c o m*/ case Gravity.TOP: mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset; break; } switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mCollapsedDrawX = mCollapsedBounds.right - width; break; case Gravity.LEFT: default: mCollapsedDrawX = mCollapsedBounds.left; break; } calculateUsingTextSize(mExpandedTextSize); width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mExpandedDrawY = mExpandedBounds.bottom; break; case Gravity.TOP: mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mExpandedDrawY = mExpandedBounds.centerY() + textOffset; break; } switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mExpandedDrawX = mExpandedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mExpandedDrawX = mExpandedBounds.right - width; break; case Gravity.LEFT: default: mExpandedDrawX = mExpandedBounds.left; break; } // The bounds have changed so we need to clear the texture clearTexture(); // Now reset the text size back to the original setInterpolatedTextSize(currentTextSize); }
From source file:com.hippo.drawerlayout.DrawerLayout.java
public void setDrawerLockMode(int lockMode, int gravity) { if (gravity == Gravity.LEFT) { setDrawerLockMode(lockMode, mLeftDrawer); } else if (gravity == Gravity.RIGHT) { setDrawerLockMode(lockMode, mRightDrawer); } else {/*from w ww. j a v a2s . c om*/ throw new IllegalArgumentException("gravity must be Gravity.LEFT or Gravity.RIGHT"); } }
From source file:com.sanron.sunweather.view.v4.DrawerLayout.java
public DrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); final float density = getResources().getDisplayMetrics().density; mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f); final float minVel = MIN_FLING_VELOCITY * density; mLeftCallback = new ViewDragCallback(Gravity.LEFT); mRightCallback = new ViewDragCallback(Gravity.RIGHT); mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback); mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); mLeftDragger.setMinVelocity(minVel); mLeftCallback.setDragger(mLeftDragger); mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback); mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT); mRightDragger.setMinVelocity(minVel); mRightCallback.setDragger(mRightDragger); // So that we can catch the back button setFocusableInTouchMode(true);/*from w w w . j av a 2 s . c o m*/ ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); if (ViewCompat.getFitsSystemWindows(this)) { IMPL.configureApplyInsets(this); } }
From source file:com.mobicage.rogerthat.ServiceBoundActivity.java
protected int getFabGravity() { return Gravity.BOTTOM | Gravity.RIGHT; }
From source file:com.amitupadhyay.aboutexample.util.CollapsingTextHelper.java
private void calculateBaseOffsets() { // We then calculate the collapsed text size, using the same logic mTextPaint.setTextSize(mCollapsedTextSize); float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mCollapsedDrawY = mCollapsedBounds.bottom; break;/*from w w w . j a v a 2 s.c om*/ case Gravity.TOP: mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset; break; } switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mCollapsedDrawX = mCollapsedBounds.right - width; break; case Gravity.LEFT: default: mCollapsedDrawX = mCollapsedBounds.left; break; } mTextPaint.setTextSize(mExpandedTextSize); width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mExpandedDrawY = mExpandedBounds.bottom; break; case Gravity.TOP: mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mExpandedDrawY = mExpandedBounds.centerY() + textOffset; break; } switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mExpandedDrawX = mExpandedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mExpandedDrawX = mExpandedBounds.right - width; break; case Gravity.LEFT: default: mExpandedDrawX = mExpandedBounds.left; break; } // The bounds have changed so we need to clear the texture clearTexture(); }
From source file:com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout.java
public int getDrawerLockMode(int gravity) { if (gravity == Gravity.LEFT) return getDrawerLockMode(mLeftDrawer); else if (gravity == Gravity.RIGHT) return getDrawerLockMode(mRightDrawer); else/* ww w.jav a 2 s . c o m*/ throw new IllegalArgumentException("gravity must be Gravity.LEFT or Gravity.RIGHT"); }
From source file:com.cyanogenmod.filemanager.ui.widgets.DrawerLayout.java
/** * Enable or disable interaction with the given drawer. * * <p>This allows the application to restrict the user's ability to open or close * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)}, * {@link #closeDrawer(int)} and friends if a drawer is locked.</p> * * <p>Locking a drawer open or closed will implicitly open or close * that drawer as appropriate.</p> * * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED}, * {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}. * @param edgeGravity Gravity.LEFT, RIGHT, START or END. * Expresses which drawer to change the mode for. * * @see #LOCK_MODE_UNLOCKED// ww w. jav a2 s . c o m * @see #LOCK_MODE_LOCKED_CLOSED * @see #LOCK_MODE_LOCKED_OPEN */ public void setDrawerLockMode(int lockMode, int edgeGravity) { final int absGravity = Gravity.getAbsoluteGravity(edgeGravity, this.getLayoutDirection()); if (absGravity == Gravity.LEFT) { mLockModeLeft = lockMode; } else if (absGravity == Gravity.RIGHT) { mLockModeRight = lockMode; } if (lockMode != LOCK_MODE_UNLOCKED) { // Cancel interaction in progress final ViewDragHelper helper = absGravity == Gravity.LEFT ? mLeftDragger : mRightDragger; helper.cancel(); } switch (lockMode) { case LOCK_MODE_LOCKED_OPEN: final View toOpen = findDrawerWithGravity(absGravity); if (toOpen != null) { openDrawer(toOpen); } break; case LOCK_MODE_LOCKED_CLOSED: final View toClose = findDrawerWithGravity(absGravity); if (toClose != null) { closeDrawer(toClose); } break; // default: do nothing } }
From source file:com.hippo.nimingban.ui.ListActivity.java
private void showRightDrawerGuide() { new GuideHelper.Builder(this).setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary)) .setPadding(LayoutUtils.dp2pix(this, 16)).setMessagePosition(Gravity.RIGHT) .setMessage(getString(R.string.swipe_left_open_forum_list)).setButton(getString(R.string.get_it)) .setBackgroundColor(0x73000000).setOnDissmisListener(new View.OnClickListener() { @Override//from w w w.ja va 2s . c om public void onClick(View v) { showToolbarGuide(); } }).show(); }
From source file:com.hippo.ehviewer.ui.MainActivity.java
@Override public void onSceneViewCreated(SceneFragment scene, Bundle savedInstanceState) { super.onSceneViewCreated(scene, savedInstanceState); if (scene instanceof BaseScene && mRightDrawer != null && mDrawerLayout != null) { BaseScene baseScene = (BaseScene) scene; mRightDrawer.removeAllViews();/* w w w. j a va2 s . com*/ View drawerView = baseScene.onCreateDrawerView(getLayoutInflater(), mRightDrawer, savedInstanceState); if (drawerView != null) { mRightDrawer.addView(drawerView); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); } else { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT); } } }
From source file:com.cosmicsubspace.nerdyaudio.ui.MainActivity.java
@Override public void onClick(View view) { int id = view.getId(); /*//w ww .ja va 2 s.c om if (id==R.id.controls_play){ if (ap!=null){ if (ap.isPlaying()){ ap.pause(); play.setBackgroundResource(R.drawable.ic_play_arrow_white_48dp); }else if (ap.isPaused()){ ap.playAudio(); play.setBackgroundResource(R.drawable.ic_pause_white_48dp); }else{ qm.play(); play.setBackgroundResource(R.drawable.ic_pause_white_48dp); } } }else if (id==R.id.settings_btn){ dl.openDrawer(Gravity.RIGHT); }else if (id==R.id.controls_fastforward){ qm.playNextFile(); }else if (id==R.id.controls_rewind){ qm.playPreviousFile(); }*/ if (id == R.id.settings_btn) { dl.openDrawer(Gravity.RIGHT); } }