Example usage for android.view Gravity RIGHT

List of usage examples for android.view Gravity RIGHT

Introduction

In this page you can find the example usage for android.view Gravity RIGHT.

Prototype

int RIGHT

To view the source code for android.view Gravity RIGHT.

Click Source Link

Document

Push object to the right of its container, not changing its size.

Usage

From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java

/**
 * Creates the input amount dialog.//from ww  w.j  a  va 2s.  c o  m
 * @param parentActivity Activity used to access application resources.
 */
private void buildInputMoneyDialog(Activity parentActivity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity, AlertDialog.THEME_HOLO_DARK);
    builder.setTitle(getString(R.string.amount_dialog_title));
    builder.setMessage(getString(R.string.amount_dialog_label));
    builder.setPositiveButton(getString(R.string.save_amount), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            // Set text of the dialog edit text to the amount button.
            double amountText = 0;
            String dialogText = mAmountTextDago.getText().toString();
            if (dialogText != null && !dialogText.isEmpty()) {
                amountText = Double.valueOf(dialogText);
            }

            // Close this dialog.
            dialog.dismiss();
            mButtonAmount.setText(StringFormatter.formatCurrency(amountText));
        }
    });

    builder.setNegativeButton(getString(R.string.cancel_amount), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Cancel this dialog.
            dialog.cancel();
        }
    });

    // Setup the input for the user.
    mAmountTextDago = new EditText(parentActivity);
    mAmountTextDago.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
    mAmountTextDago.setGravity(Gravity.RIGHT);
    mAmountTextDago.setFilters(new InputFilter[] { new DecimalDigitsInputFiler(16, 2) });
    mAmountTextDago.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
    mAmountTextDago.setTextColor(getResources().getColor(R.color.text_white));

    mAmountTextDago.setTypeface(StringFormatter.createLightFont());

    // Assign this view to the dialog.
    builder.setView(mAmountTextDago);
    mInputMoneyDialog = builder.create();

    displayDialogKeyboard();

}

From source file:android.car.ui.provider.CarDrawerLayout.java

/**
 * Check the lock mode of the given drawer view.
 *
 * @param drawerView Drawer view to check lock mode
 * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or
 *         {@link #LOCK_MODE_LOCKED_OPEN}.
 *//*from  w  ww.  j  a v  a2  s .  c  o m*/
public int getDrawerLockMode(View drawerView) {
    final int absGravity = getDrawerViewAbsoluteGravity(drawerView);
    if (absGravity == Gravity.LEFT) {
        return mLockModeLeft;
    } else if (absGravity == Gravity.RIGHT) {
        return mLockModeRight;
    }
    return LOCK_MODE_UNLOCKED;
}

From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java

private void guideQuickSearch() {
    Activity activity = getActivity2();/*from  www  . j a  v  a2s.c o m*/
    if (null == activity || !Settings.getGuideQuickSearch()) {
        return;
    }

    Display display = activity.getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);

    mShowcaseView = new ShowcaseView.Builder(activity).withMaterialShowcase().setStyle(R.style.Guide)
            .setTarget(new PointTarget(point.x, point.y / 3)).blockAllTouches()
            .setContentTitle(R.string.guide_quick_search_title).setContentText(R.string.guide_quick_search_text)
            .replaceEndButton(R.layout.button_guide)
            .setShowcaseEventListener(new SimpleShowcaseEventListener() {
                @Override
                public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
                    mShowcaseView = null;
                    ViewUtils.removeFromParent(showcaseView);
                    Settings.putGuideQuickSearch(false);
                    openDrawer(Gravity.RIGHT);
                }
            }).build();
}

From source file:com.google.blockly.android.ToolboxFragment.java

/**
 * @return Computed {@link Rotation} constant for {@link #mRotateTabs} and {@link #mTabEdge}.
 *//*from ww  w  .j  ava 2 s.  co  m*/
@Rotation.Enum
private int getLabelRotation() {
    if (!mRotateTabs) {
        return Rotation.NONE;
    }
    switch (mTabEdge) {
    case Gravity.LEFT:
        return Rotation.COUNTER_CLOCKWISE;
    case Gravity.RIGHT:
        return Rotation.CLOCKWISE;
    case Gravity.TOP:
        return Rotation.NONE;
    case Gravity.BOTTOM:
        return Rotation.NONE;
    case GravityCompat.START:
        return Rotation.ADAPTIVE_COUNTER_CLOCKWISE;
    case GravityCompat.END:
        return Rotation.ADAPTIVE_CLOCKWISE;
    default:
        throw new IllegalArgumentException("Invalid tabEdge: " + mTabEdge);
    }
}

From source file:com.muzakki.ahmad.widget.CollapsingTextHelper.java

private void calculateBaseOffsets() {
    final float currentTextSize = mCurrentTextSize;

    // We then calculate the collapsed text size, using the same logic
    calculateUsingTextSize(mCollapsedTextSize);
    calculateUsingSubSize(mCollapsedSubSize);

    float textHeight = mTextPaint.descent() - mTextPaint.ascent();
    float textOffset = (textHeight / 2);
    if (mSub != null) {
        float subHeight = mSubPaint.descent() - mSubPaint.ascent();
        float subOffset = (subHeight / 2) - mSubPaint.descent();
        float offset = ((mCollapsedBounds.height() - (textHeight + subHeight)) / 3);

        mCollapsedDrawY = mCollapsedBounds.top + offset - mTextPaint.ascent();
        mCollapsedSubY = mCollapsedBounds.top + (offset * 2) + textHeight - mSubPaint.ascent();
    } else { // title only
        mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset;
    }//from   w  w  w.j  a  v a2 s  .  c o  m

    float width = mText != null ? mTextPaint.measureText(mText, 0, mText.length()) : 0;
    float subWidth = mSub != null ? mSubPaint.measureText(mSub, 0, mSub.length()) : 0;
    final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);

    switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2);
        mCollapsedDrawSubX = mCollapsedBounds.centerX() - (subWidth / 2);
        break;
    case Gravity.RIGHT:
        mCollapsedDrawX = mCollapsedBounds.right - width;
        mCollapsedDrawSubX = mCollapsedBounds.right - subWidth;
        break;
    case Gravity.LEFT:
    default:
        mCollapsedDrawX = mCollapsedBounds.left;
        mCollapsedDrawSubX = mCollapsedBounds.left;
        break;
    }

    calculateUsingTextSize(mExpandedTextSize);
    calculateUsingSubSize(mExpandedSubSize);

    textHeight = mTextPaint.descent() - mTextPaint.ascent();
    textOffset = (textHeight / 2);
    if (mSub != null) {
        float subHeight = mSubPaint.descent() - mSubPaint.ascent();
        float subOffset = (subHeight / 2);

        mExpandedDrawY = mExpandedBounds.centerY() + textOffset;
        mExpandedSubY = mExpandedDrawY + subOffset - mSubPaint.ascent();
    } else { // title only
        mExpandedDrawY = mExpandedBounds.centerY() + textOffset;
    }

    width = mText != null ? mTextPaint.measureText(mText, 0, mText.length()) : 0;
    subWidth = mSub != null ? mSubPaint.measureText(mSub, 0, mSub.length()) : 0;
    final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mExpandedDrawX = mExpandedBounds.centerX() - (width / 2);
        mExpandedDrawSubX = mExpandedBounds.centerX() - (subWidth / 2);
        break;
    case Gravity.RIGHT:
        mExpandedDrawX = mExpandedBounds.right - width;
        mExpandedDrawSubX = mExpandedBounds.right - subWidth;
        break;
    case Gravity.LEFT:
    default:
        mExpandedDrawX = mExpandedBounds.left;
        mExpandedDrawSubX = 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.aidy.bottomdrawerlayout.AllDrawerLayout.java

/**
 * Check the lock mode of the drawer with the given gravity.
 * // w  w w.  j a va  2 s.c  om
 * @param edgeGravity
 *            Gravity of the drawer to check
 * @return one of {@link #LOCK_MODE_UNLOCKED},
 *         {@link #LOCK_MODE_LOCKED_CLOSED} or
 *         {@link #LOCK_MODE_LOCKED_OPEN}.
 */
public int getDrawerLockMode(int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    switch (absGravity) {
    case Gravity.LEFT:
        return mLockModeLeft;
    case Gravity.RIGHT:
        return mLockModeRight;
    case Gravity.TOP:
        return mLockModeTop;
    case Gravity.BOTTOM:
        return mLockModeBottom;
    default:
        return LOCK_MODE_UNLOCKED;
    }
}

From source file:com.dk.view.FolderDrawerLayout.java

/**
 * Sets the title of the drawer with the given gravity.
 * <p>/*w w  w .  j a v  a 2s.co  m*/
 * When accessibility is turned on, this is the title that will be used to
 * identify the drawer to the active accessibility service.
 * 
 * @param edgeGravity
 *            Gravity.LEFT, RIGHT, START or END. Expresses which drawer to
 *            set the title for.
 * @param title
 *            The title for the drawer.
 */
public void setDrawerTitle(int edgeGravity, CharSequence title) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.LEFT) {
        mTitleLeft = title;
    } else if (absGravity == Gravity.RIGHT) {
        mTitleRight = title;
    }
}

From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java

/**
 * Set a simple drawable used for the left or right shadow. The drawable provided must have a
 * nonzero intrinsic width. For API 21 and above, an elevation will be set on the drawer
 * instead of the drawable provided.//from  w  ww . j  av  a2s .  c o  m
 *
 * <p>Note that for better support for both left-to-right and right-to-left layout
 * directions, a drawable for RTL layout (in additional to the one in LTR layout) can be
 * defined with a resource qualifier "ldrtl" for API 17 and above with the gravity
 * {@link GravityCompat#START}. Alternatively, for API 23 and above, the drawable can
 * auto-mirrored such that the drawable will be mirrored in RTL layout.</p>
 *
 * @param shadowDrawable Shadow drawable to use at the edge of a drawer
 * @param gravity Which drawer the shadow should apply to
 */
public void setDrawerShadow(Drawable shadowDrawable, @EdgeGravity int gravity) {
    /*
     * TODO Someone someday might want to set more complex drawables here.
     * They're probably nuts, but we might want to consider registering callbacks,
     * setting states, etc. properly.
     */
    if (SET_DRAWER_SHADOW_FROM_ELEVATION) {
        // No op. Drawer shadow will come from setting an elevation on the drawer.
        return;
    }
    if ((gravity & GravityCompat.START) == GravityCompat.START) {
        mShadowStart = shadowDrawable;
    } else if ((gravity & GravityCompat.END) == GravityCompat.END) {
        mShadowEnd = shadowDrawable;
    } else if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
        mShadowLeft = shadowDrawable;
    } else if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) {
        mShadowRight = shadowDrawable;
    } else {
        return;
    }
    resolveShadowDrawables();
    invalidate();
}

From source file:com.money.manager.ex.home.DashboardFragment.java

private View showTableLayoutUpComingTransactions(Cursor cursor) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null);
    CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext());
    Core core = new Core(getActivity().getApplicationContext());

    // Textview Title
    TextView title = (TextView) layout.findViewById(R.id.textViewTitle);
    title.setText(R.string.upcoming_transactions);
    // Table/* w w w. j a  v  a  2 s.co  m*/
    TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary);
    // add rows
    while (cursor.moveToNext()) {
        // load values
        String payee = "<i>" + cursor.getString(cursor.getColumnIndex(QueryBillDeposits.PAYEENAME)) + "</i>";
        double total = cursor.getDouble(cursor.getColumnIndex(QueryBillDeposits.AMOUNT));
        int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT));
        int currencyId = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID));
        String daysLeftText = "";
        daysLeftText = Integer.toString(Math.abs(daysLeft)) + " "
                + getString(daysLeft >= 0 ? R.string.days_remaining : R.string.days_overdue);
        TableRow row = createTableRow(
                new String[] { "<small>" + payee + "</small>",
                        "<small>" + currencyService.getCurrencyFormatted(currencyId,
                                MoneyFactory.fromDouble(total)) + "</small>",
                        "<small>" + daysLeftText + "</small>" },
                new Float[] { 1f, null, 1f }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT },
                new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null });
        TextView txt = (TextView) row.getChildAt(2);
        UIHelper uiHelper = new UIHelper(getActivity());
        int color = daysLeft >= 0 ? uiHelper.resolveAttribute(R.attr.holo_green_color_theme)
                : uiHelper.resolveAttribute(R.attr.holo_red_color_theme);
        txt.setTextColor(ContextCompat.getColor(getActivity(), color));
        // Add Row
        tableLayout.addView(row);
    }
    // return Layout
    return layout;
}

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

/**
 * Check the lock mode of the drawer with the given gravity.
 *
 * @param edgeGravity Gravity of the drawer to check
 * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or
 *         {@link #LOCK_MODE_LOCKED_OPEN}.
 *//*from w  ww .j  a v a  2s  .  com*/
@LockMode
public int getDrawerLockMode(@EdgeGravity int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.LEFT) {
        return mLockModeLeft;
    } else if (absGravity == Gravity.RIGHT) {
        return mLockModeRight;
    }
    return LOCK_MODE_UNLOCKED;
}