Example usage for android.view Gravity BOTTOM

List of usage examples for android.view Gravity BOTTOM

Introduction

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

Prototype

int BOTTOM

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

Click Source Link

Document

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

Usage

From source file:com.p3authentication.preferences.Prefs.java

@SuppressWarnings("static-access")
public void tolerance_dialog() {
    // TODO Auto-generated method stub
    final AlertDialog.Builder tol = new AlertDialog.Builder(Prefs.this);
    final LayoutInflater inflater = (LayoutInflater) Prefs.this
            .getSystemService(Prefs.this.LAYOUT_INFLATER_SERVICE);
    final View Viewlayout = inflater.inflate(R.layout.tolerance_dialog,
            (ViewGroup) findViewById(R.id.tolerance_layout));
    tol.setTitle("Please adjust the tolerance");
    tol.setView(Viewlayout);/*from  ww  w. ja  v a 2s .  co m*/

    calibrator = (ImageView) Viewlayout.findViewById(R.id.iv_calibrator);
    fingsize = (TextView) Viewlayout.findViewById(R.id.tv_size);
    Largest = (TextView) Viewlayout.findViewById(R.id.tv_largest);
    CalList = new ArrayList<Float>();
    tol.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            int i = LargeValue.intValue();
            int screenWidth = (int) ((getWindowManager().getDefaultDisplay().getWidth()) * 0.055);
            if (i > screenWidth) {
                PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit()
                        .putInt("tolerance", i).apply();
            }
            dialog.dismiss();
        }

    });
    tol.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            dialog.dismiss();
        }
    });
    calibrator.setOnTouchListener(this);
    final AlertDialog tolDialog = tol.create();

    WindowManager.LayoutParams wmlp = tolDialog.getWindow().getAttributes();
    wmlp.gravity = Gravity.BOTTOM;
    tolDialog.show();

}

From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java

/**
 * Returns the title of the drawer with the given gravity.
 * /*from  w ww .j  a  v a 2  s  . com*/
 * @param edgeGravity
 *            Gravity.LEFT, RIGHT, START or END. Expresses which
 *            drawer to return the title for.
 * @return The title of the drawer, or null if none set.
 * @see #setDrawerTitle(int, CharSequence)
 */
public CharSequence getDrawerTitle(int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.TOP) {
        return mTitleTop;
    } else if (absGravity == Gravity.BOTTOM) {
        return mTitleBottom;
    }
    return null;
}

From source file:com.amazon.appstream.sampleclient.SampleClientActivity.java

@Override
public void onErrorMessage(final boolean fatal, final String message) {
    runOnUiThread(new Runnable() {
        @Override//  ww w  .ja  v  a  2s.co  m
        public void run() {
            if (mStopped) {
                Log.i(TAG, "Ignoring error during stopped state :" + (fatal ? "fatal" : "non fatal") + ":"
                        + message);
                return; // ignore errors if we're stopped.
            }
            if (fatal) {
                // Tell the app it needs to pause.
                AppStreamInterface.pause(true);
                ErrorDialogFragment dialog = new ErrorDialogFragment();
                dialog.setMessage(message);
                dialog.show(getSupportFragmentManager(), "ErrorDialogFragment");

                // And finally stop AppStream; kill the interfaces to give us a clean slate.
                stopAppStream();
            } else {
                if (mConnectDialog != null) {
                    openConnectDialog(message);
                } else {
                    Toast toast = Toast.makeText(SampleClientActivity.this, message, Toast.LENGTH_LONG);
                    toast.setGravity(Gravity.RIGHT | Gravity.BOTTOM, 10, 10);
                    toast.show();
                }
            }
        }
    });
}

From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java

/**
 * Check the lock mode of the given drawer view.
 * /*from   w  w w.j  a v a 2  s . c o  m*/
 * @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}.
 */
public int getDrawerLockMode(View drawerView) {
    final int absGravity = getDrawerViewAbsoluteGravity(drawerView);
    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.android.mail.ui.TwoPaneController.java

/**
 * Set the toast bar's layout params to position it in the right place
 * depending the current view mode./* w  ww  .j  a  v a2 s . co m*/
 *
 * @param convModeShowInList if we're in conversation mode, should the toast
 *            bar appear over the list? no effect when not in conversation mode.
 */
private void repositionToastBar(boolean convModeShowInList) {
    final int mode = mViewMode.getMode();
    final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mToastBar.getLayoutParams();
    switch (mode) {
    case ViewMode.SEARCH_RESULTS_LIST:
    case ViewMode.CONVERSATION_LIST:
        params.width = mLayout.computeConversationListWidth() - params.leftMargin - params.rightMargin;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        mToastBar.setLayoutParams(params);
        break;
    case ViewMode.SEARCH_RESULTS_CONVERSATION:
    case ViewMode.CONVERSATION:
        if (convModeShowInList && !mLayout.isConversationListCollapsed()) {
            // Show undo bar in the conversation list.
            params.gravity = Gravity.BOTTOM | Gravity.LEFT;
            params.width = mLayout.computeConversationListWidth() - params.leftMargin - params.rightMargin;
            mToastBar.setLayoutParams(params);
        } else {
            // Show undo bar in the conversation.
            params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
            params.width = mLayout.computeConversationWidth() - params.leftMargin - params.rightMargin;
            mToastBar.setLayoutParams(params);
        }
        break;
    }
}

From source file:com.sonvp.tooltip.Tooltip.java

/**
 * change gravity tooltip if anchorView intersect display screen
 *//*w  w w  . ja va2s.  co m*/
private void changeGravityToolTip() {

    Context context = container.getContext();
    if (!(context instanceof Activity)) {
        return;
    }
    DisplayMetrics displayMetrics = new DisplayMetrics();
    ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int displayHeight = displayMetrics.heightPixels;
    int displayWidth = displayMetrics.widthPixels;
    int displayTop = getStatusBarHeight();

    int anchorTop = rectAnchorView.top;
    int anchorLeft = rectAnchorView.left;
    int anchorHeight = anchorView.getHeight();
    int anchorWidth = anchorView.getWidth();

    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(displayWidth, View.MeasureSpec.AT_MOST);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    viewTooltip.measure(widthMeasureSpec, heightMeasureSpec);

    int textHeight = viewTooltip.getMeasuredHeight(); // height multi line
    int heightToolTip = textHeight + // with Gravity is Top and Bottom
            (int) builder.arrowHeight + (int) builder.topPadding + (int) builder.bottomPadding
            + (int) builder.toolTipMargin;

    int textWidth = viewTooltip.getMeasuredHeight();
    int widthToolTip = textWidth + // with Gravity is Left and Right
            (int) builder.arrowWidth + (int) builder.leftPadding + (int) builder.rightPadding
            + (int) builder.toolTipMargin;

    switch (gravity) {
    case Gravity.LEFT:

        if (!(viewTooltip instanceof TextView)) {
            if (anchorLeft < widthToolTip) {
                if (anchorTop > heightToolTip) {
                    gravity = Gravity.TOP;
                } else {
                    gravity = Gravity.BOTTOM;
                }
            }
        }

    case Gravity.RIGHT:

        if (!(viewTooltip instanceof TextView)) {
            int anchorRight = anchorLeft + anchorWidth;
            if (anchorRight + widthToolTip > displayWidth) {
                if (anchorTop > heightToolTip) {
                    gravity = Gravity.TOP;
                } else {
                    gravity = Gravity.BOTTOM;
                }
            }
        }

    default: // with Gravity is Left and Right
        int anchorVerticalCenter = anchorTop + anchorHeight / 2;
        int bottomArrow = anchorVerticalCenter + (int) builder.arrowHeight / 2;
        int topArrow = anchorVerticalCenter - (int) builder.arrowHeight / 2;
        if (bottomArrow + builder.radius + builder.toolTipMargin > displayHeight) {
            gravity = Gravity.TOP;
        } else if (topArrow < getStatusBarHeight() + builder.radius + builder.toolTipMargin) {
            gravity = Gravity.BOTTOM;
        }
        break;

    case Gravity.TOP:
        if (anchorTop - displayTop < heightToolTip) {
            gravity = Gravity.BOTTOM;
        }
        break;

    case Gravity.BOTTOM:
        int anchorBottom = displayHeight - (anchorTop + anchorHeight);
        if (anchorBottom < heightToolTip) {
            gravity = Gravity.TOP;
        }
        break;
    }
}

From source file:info.hl.mediam.GroupProfileActivity.java

private void getImageDialog() {
    final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme);
    imageDialog.getWindow().setGravity(Gravity.BOTTOM);
    imageDialog.setContentView(R.layout.dialog_get_image);
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
    Window window = imageDialog.getWindow();
    layoutParams.copyFrom(window.getAttributes());
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(layoutParams);//  w  w  w  .  j av a  2  s .  com

    final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery);
    btnGallery.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnGallery.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            galleryIntent.putExtra("type", "gallery");
            galleryIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera);
    btnCamera.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnCamera.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            cameraIntent.putExtra("type", "camera");
            cameraIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto);
    btnRemovePhoto.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnRemovePhoto.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            mGroupAvatarId = "";
            gGroupImage = null;
            Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE,
                    R.drawable.group_stub_large, false);
            imageDialog.dismiss();

        }
    });

    imageDialog.show();
}

From source file:com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    mInLayout = true;/*from  w  w w . j ava  2 s  .  c o  m*/
    final int width = r - l;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);

        if (child.getVisibility() == GONE) {
            continue;
        }

        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        int paddingTop = 0;
        int paddingBottom = mFitPaddingBottom;
        if (child instanceof DrawerLayoutChild) {
            DrawerLayoutChild dlc = (DrawerLayoutChild) child;
            paddingTop = dlc.getLayoutPaddingTop();
            paddingBottom = dlc.getLayoutPaddingBottom() + mFitPaddingBottom;
        }
        if (child == mContentView) {
            child.layout(lp.leftMargin, lp.topMargin + paddingTop, lp.leftMargin + child.getMeasuredWidth(),
                    lp.topMargin + paddingTop + child.getMeasuredHeight());
        } else if (child == mShadow) {
            child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
        } else { // Drawer, if it wasn't onMeasure would have thrown an exception.
            final int childWidth = child.getMeasuredWidth();
            final int childHeight = child.getMeasuredHeight();
            int childLeft;
            float percent;

            if (child == mLeftDrawer) {
                percent = mLeftPercent;
                childLeft = -childWidth + (int) (childWidth * percent);
            } else { // Right; onMeasure checked for us.
                percent = mRightPercent;
                childLeft = width - (int) (childWidth * percent);
            }

            final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;

            switch (vgrav) {
            default:
            case Gravity.TOP: {
                child.layout(childLeft, lp.topMargin + paddingTop, childLeft + childWidth,
                        lp.topMargin + paddingTop + childHeight);
                break;
            }

            case Gravity.BOTTOM: {
                final int height = b - t;
                child.layout(childLeft, height - lp.bottomMargin - paddingBottom - child.getMeasuredHeight(),
                        childLeft + childWidth, height - lp.bottomMargin - paddingBottom);
                break;
            }

            case Gravity.CENTER_VERTICAL: {
                final int height = b - t;
                int childTop = (height - childHeight - paddingTop - paddingBottom - lp.topMargin
                        - lp.bottomMargin) / 2 + paddingTop;
                // Offset for margins. If things don't fit right because of
                // bad measurement before, oh well.
                if (childTop < lp.topMargin + paddingTop) {
                    childTop = lp.topMargin + paddingTop;
                } else if (childTop + childHeight > height - paddingBottom - lp.bottomMargin) {
                    childTop = height - paddingBottom - lp.bottomMargin - childHeight;
                }
                child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
                break;
            }
            }

            final int newVisibility = percent > 0 ? VISIBLE : INVISIBLE;
            if (child.getVisibility() != newVisibility) {
                child.setVisibility(newVisibility);
            }
        }
    }
    mInLayout = false;
}

From source file:com.cloverstudio.spika.GroupProfileActivity.java

private void getImageDialog() {
    final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme);
    imageDialog.getWindow().setGravity(Gravity.BOTTOM);
    imageDialog.setContentView(R.layout.dialog_get_image);
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
    Window window = imageDialog.getWindow();
    layoutParams.copyFrom(window.getAttributes());
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(layoutParams);//from  w w w. j  a v a2  s.  c  o m

    final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery);
    btnGallery.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnGallery.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            galleryIntent.putExtra("type", "gallery");
            galleryIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera);
    btnCamera.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnCamera.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            cameraIntent.putExtra("type", "camera");
            cameraIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto);
    btnRemovePhoto.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnRemovePhoto.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            mGroupAvatarId = "";
            gGroupImage = null;
            Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE,
                    R.drawable.group_stub_large, false);
            imageDialog.dismiss();

        }
    });

    imageDialog.show();
}

From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java

/**
 * Simple gravity to string - only supports TOP and BOTTOM for debugging output.
 *
 * @param gravity Absolute gravity value
 * @return TOP or BOTTOM as appropriate, or a hex string
 *///from  ww w .j av a 2  s.c o  m
static String gravityToString(int gravity) {
    if ((gravity & Gravity.TOP) == Gravity.TOP) {
        return "TOP";
    }
    if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        return "BOTTOM";
    }
    return Integer.toHexString(gravity);
}