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.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  ava 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:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java

public void setGravity(int gravity) {
    if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
        throw new IllegalArgumentException("gravity must be set to either top or bottom");
    }/*from www  . j ava  2 s .c  o m*/
    mIsSlidingUp = gravity == Gravity.BOTTOM;
    if (!mFirstLayout) {
        requestLayout();
    }
}

From source file:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);//w ww. j a v  a2 s  .  c  o m
    View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null);
    final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    //??
    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    popupWindow.setWidth(dm.widthPixels);
    popupWindow.setAnimationStyle(R.style.popuwindow);
    //?
    popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
    popupWindow.setOnDismissListener(new poponDismissListener_CompanyApplyFragment());

    //PopupWindow-----END
    //PopupWindow
    Button button = (Button) view.findViewById(R.id.take_photo);//??
    Button button1 = (Button) view.findViewById(R.id.all_photo);//?
    Button button2 = (Button) view.findViewById(R.id.out);//?
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
        }
    });
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,?
            Log.i("Daniel", "------");
            allPhoto();
        }
    });
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,Intent????
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //,??
            File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image");
            //??
            path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg";
            //?IntentIntent?
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
            //?
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
            //?Intent??RoundImageView
            startActivityForResult(intent, REQUEST_CODE);
        }
    });
}

From source file:com.androidhuman.circlerefreshlayout.SwipeRefreshLayout.java

public void setPullPosition(@PullPosition int position) {
    if (position != Gravity.TOP && position != Gravity.BOTTOM) {
        return;/*from   w ww . j  av  a  2s.  co  m*/
    }
    mPullPosition = position;
    mOriginalOffsetEdge = getBottom();
}

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

/**
 * Enable or disable interaction with all drawers.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * any drawer within this layout. VerticalDrawerLayout will still respond to calls to
 * {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking drawers open or closed will implicitly open or close
 * any drawers 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}.
 *///from w  w w .  j a  va2 s . c o  m
public void setDrawerLockMode(int lockMode) {
    setDrawerLockMode(lockMode, Gravity.TOP);
    setDrawerLockMode(lockMode, Gravity.BOTTOM);
}

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

/**
 * Set a simple drawable used for the left or right shadow. The drawable
 * provided must have a nonzero intrinsic width.
 * //w ww .j a v  a  2s  .c o m
 * @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, 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.
     */

    final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
    if ((absGravity & Gravity.LEFT) == Gravity.LEFT) {
        mShadowLeft = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) {
        mShadowRight = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.TOP) == Gravity.TOP) {
        mShadowTop = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        mShadowBottom = shadowDrawable;
        invalidate();
    }
}

From source file:com.example.angelina.travelapp.map.MapFragment.java

@Override
public void showRouteDetail(final int position) {
    // Remove the route header view,
    ////from   w w  w  .j  av a 2s.  c  om
    //since we're replacing it with a different header

    removeRouteHeaderView();
    // State  and stage flags
    mCurrentPosition = position;
    mShowingRouteDetail = true;

    // Hide action bar
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (ab != null) {
        ab.hide();
    }

    // Display route detail header
    final LayoutInflater inflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final LinearLayout.LayoutParams routeDetailLayout = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    if (mRouteHeaderDetail == null) {
        mRouteHeaderDetail = (LinearLayout) inflater.inflate(R.layout.route_detail_header, null);
        TextView title = (TextView) mRouteHeaderDetail.findViewById(R.id.route_txt_detail);
        title.setText("Route Detail");

        mRouteHeaderDetail.setBackgroundColor(Color.WHITE);
        mMapView.addView(mRouteHeaderDetail, routeDetailLayout);
        mMapView.requestLayout();

        // Attach a listener to the back arrow
        ImageView imageBtn = (ImageView) mRouteHeaderDetail.findViewById(R.id.btnDetailHeaderClose);
        imageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Navigate back to directions list
                mShowingRouteDetail = false;
                ((MapActivity) getActivity()).showDirections(mRouteDirections);
            }
        });
    }

    // Display arrows to scroll through directions
    if (mSegmentNavigator == null) {
        mSegmentNavigator = (LinearLayout) inflater.inflate(R.layout.navigation_arrows, null);
        final FrameLayout navigatorLayout = (FrameLayout) getActivity()
                .findViewById(R.id.map_fragment_container);
        FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
                Gravity.BOTTOM | Gravity.END);
        frameLayoutParams.setMargins(0, 0, 0, 80);
        navigatorLayout.addView(mSegmentNavigator, frameLayoutParams);
        navigatorLayout.requestLayout();
        // Add button click listeners
        Button btnPrev = (Button) getActivity().findViewById(R.id.btnBack);

        btnPrev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition > 0) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition - 1));
                    mCurrentPosition = mCurrentPosition - 1;
                }

            }
        });
        Button btnNext = (Button) getActivity().findViewById(R.id.btnNext);
        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition < mRouteDirections.size() - 1) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition + 1));
                    mCurrentPosition = mCurrentPosition + 1;
                }

            }
        });
    }

    // Populate with directions
    DirectionManeuver maneuver = mRouteDirections.get(position);
    populateViewWithRouteDetail(maneuver);

}

From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java

/**
 * Called by Constructor to provide fragment transitions.  The default implementation assigns
 * transitions based on {@link #getUiStyle()}:
 * <ul>/*from   w w w .  j  av a 2s  .  co  m*/
 * <li> {@link #UI_STYLE_REPLACE} Slide from/to end(right) for enter transition, slide from/to
 * start(left) for exit transition, shared element enter transition is set to ChangeBounds.
 * <li> {@link #UI_STYLE_ENTRANCE} Enter transition is set to slide from both sides, exit
 * transition is same as {@link #UI_STYLE_REPLACE}, no shared element enter transition.
 * <li> {@link #UI_STYLE_ACTIVITY_ROOT} Enter transition is set to null and app should rely on
 * activity transition, exit transition is same as {@link #UI_STYLE_REPLACE}, no shared element
 * enter transition.
 * </ul>
 * <p/>
 * The default implementation heavily relies on {@link GuidedActionsStylist} and
 * {@link GuidanceStylist} layout, app may override this method when modifying the default
 * layout of {@link GuidedActionsStylist} or {@link GuidanceStylist}.
 * <p/>
 * TIP: because the fragment view is removed during fragment transition, in general app cannot
 * use two Visibility transition together. Workaround is to create your own Visibility
 * transition that controls multiple animators (e.g. slide and fade animation in one Transition
 * class).
 */
protected void onProvideFragmentTransitions() {
    if (Build.VERSION.SDK_INT >= 21) {
        final int uiStyle = getUiStyle();
        if (uiStyle == UI_STYLE_REPLACE) {
            Object enterTransition = TransitionHelper.createFadeAndShortSlide(Gravity.END);
            TransitionHelper.exclude(enterTransition, android.support.v17.leanback.R.id.guidedstep_background,
                    true);
            TransitionHelper.exclude(enterTransition,
                    android.support.v17.leanback.R.id.guidedactions_sub_list_background, true);
            TransitionHelper.setEnterTransition(this, enterTransition);

            Object fade = TransitionHelper
                    .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT);
            TransitionHelper.include(fade, android.support.v17.leanback.R.id.guidedactions_sub_list_background);
            Object changeBounds = TransitionHelper.createChangeBounds(false);
            Object sharedElementTransition = TransitionHelper.createTransitionSet(false);
            TransitionHelper.addTransition(sharedElementTransition, fade);
            TransitionHelper.addTransition(sharedElementTransition, changeBounds);
            TransitionHelper.setSharedElementEnterTransition(this, sharedElementTransition);
        } else if (uiStyle == UI_STYLE_ENTRANCE) {
            if (entranceTransitionType == SLIDE_FROM_SIDE) {
                Object fade = TransitionHelper
                        .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT);
                TransitionHelper.include(fade, android.support.v17.leanback.R.id.guidedstep_background);
                Object slideFromSide = TransitionHelper.createFadeAndShortSlide(Gravity.END | Gravity.START);
                //TransitionHelper.include(slideFromSide, android.support.v17.leanback.R.id.content_fragment);
                TransitionHelper.include(slideFromSide, android.support.v17.leanback.R.id.action_fragment_root);
                Object enterTransition = TransitionHelper.createTransitionSet(false);
                TransitionHelper.addTransition(enterTransition, fade);
                TransitionHelper.addTransition(enterTransition, slideFromSide);
                TransitionHelper.setEnterTransition(this, enterTransition);
            } else {
                Object slideFromBottom = TransitionHelper.createFadeAndShortSlide(Gravity.BOTTOM);
                TransitionHelper.include(slideFromBottom,
                        android.support.v17.leanback.R.id.guidedstep_background_view_root);
                Object enterTransition = TransitionHelper.createTransitionSet(false);
                TransitionHelper.addTransition(enterTransition, slideFromBottom);
                TransitionHelper.setEnterTransition(this, enterTransition);
            }
            // No shared element transition
            TransitionHelper.setSharedElementEnterTransition(this, null);
        } else if (uiStyle == UI_STYLE_ACTIVITY_ROOT) {
            // for Activity root, we don't need enter transition, use activity transition
            TransitionHelper.setEnterTransition(this, null);
            // No shared element transition
            TransitionHelper.setSharedElementEnterTransition(this, null);
        }
        // exitTransition is same for all style
        Object exitTransition = TransitionHelper.createFadeAndShortSlide(Gravity.START);
        TransitionHelper.exclude(exitTransition, android.support.v17.leanback.R.id.guidedstep_background, true);
        TransitionHelper.exclude(exitTransition,
                android.support.v17.leanback.R.id.guidedactions_sub_list_background, true);
        TransitionHelper.setExitTransition(this, exitTransition);
    }
}

From source file:com.mobicage.rogerthat.ServiceBoundActivity.java

protected int getFabGravity() {
    return Gravity.BOTTOM | Gravity.RIGHT;
}

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

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case GET_IMAGE_DIALOG:
        mGetImageDialog = new Dialog(CreateGroupActivity.this, R.style.TransparentDialogTheme);
        mGetImageDialog.getWindow().setGravity(Gravity.BOTTOM);
        mGetImageDialog.setContentView(R.layout.dialog_get_image);

        // Grab the window of the dialog, and change the width
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        Window window = mGetImageDialog.getWindow();
        lp.copyFrom(window.getAttributes());
        // This makes the dialog take up the full width
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);//  ww  w  . j  a  v  a2s  .com

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

            public void onClick(View v) {

                Intent galleryIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class);
                galleryIntent.putExtra("type", "gallery");
                galleryIntent.putExtra("createGroup", true);
                CreateGroupActivity.this.startActivity(galleryIntent);
                mGetImageDialog.dismiss();

            }
        });

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

            public void onClick(View v) {

                Intent cameraIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class);
                cameraIntent.putExtra("type", "camera");
                cameraIntent.putExtra("createGroup", true);
                CreateGroupActivity.this.startActivity(cameraIntent);
                mGetImageDialog.dismiss();

            }
        });

        final Button btnRemovePhoto = (Button) mGetImageDialog.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, ImageLoader.LARGE,
                        R.drawable.group_stub_large, false);
                mGetImageDialog.dismiss();

            }
        });

        return mGetImageDialog;
    default:
        return null;
    }
}