Example usage for android.view Gravity END

List of usage examples for android.view Gravity END

Introduction

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

Prototype

int END

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

Click Source Link

Document

Push object to x-axis position at the end of its container, not changing its size.

Usage

From source file:net.grobas.blizzardleaderboards.app.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_show_drawer:
        openDrawer(Gravity.END);
        break;//from  w  ww.ja v  a 2s .  c  om
    default:
        return super.onOptionsItemSelected(item);
    }

    return true;
}

From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java

/**
 * Override methods / listeners//from www.  ja v  a2  s .c om
 */
@Override
public Object instantiateItem(ViewGroup container, int position) {
    SwipeItem slideItem = mItems.get(position);
    LinearLayout layout = null;

    switch (slideItem.iconGravity) {
    case CENTER:
    case DEFAULT:
        layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_item, null);
        break;
    case LEFT:
        layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_left_item, null);
        break;
    case RIGHT:
        layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_right_item, null);
        break;
    }

    // GET VIEW
    ImageView icon = (ImageView) layout.findViewById(R.id.swipeselector_content_icon);
    TextView title = (TextView) layout.findViewById(R.id.swipeselector_content_title);
    TextView description = (TextView) layout.findViewById(R.id.swipeselector_content_description);

    // SET VIEW
    title.setText(slideItem.title);

    if (slideItem.description == null) {
        description.setVisibility(View.GONE);
    } else {
        description.setVisibility(View.VISIBLE);
        description.setText(slideItem.description);
    }

    if (slideItem.icon == null) {
        icon.setVisibility(View.GONE);
    } else {
        icon.setImageDrawable(slideItem.icon);
        icon.setVisibility(View.VISIBLE);
    }

    // We shouldn't get here if the typeface didn't exist.
    // But just in case, because we're paranoid.
    if (mCustomTypeFace != null) {
        title.setTypeface(mCustomTypeFace);
        description.setTypeface(mCustomTypeFace);
    }

    if (mTitleTextAppearance != -1) {
        setTextAppearanceCompat(title, mTitleTextAppearance);
    }

    if (mDescriptionTextAppearance != -1) {
        setTextAppearanceCompat(description, mDescriptionTextAppearance);
    }

    switch (slideItem.titleGravity) {
    case DEFAULT:
    case CENTER:
        title.setGravity(Gravity.CENTER);
        break;
    case LEFT:
        title.setGravity(Gravity.START);
        break;
    case RIGHT:
        title.setGravity(Gravity.END);
        break;
    }

    switch (slideItem.descriptionGravity) {
    case DEFAULT:
        if (mDescriptionGravity != -1) {
            description.setGravity(mDescriptionGravity);
        } else {
            description.setGravity(Gravity.CENTER);
        }
        break;
    case CENTER:
        description.setGravity(Gravity.CENTER);
        break;
    case LEFT:
        description.setGravity(Gravity.START);
        break;
    case RIGHT:
        description.setGravity(Gravity.END);
        break;
    }

    layout.setPadding(mContentLeftPadding, mSweetSixteen, mContentRightPadding, mSweetSixteen);

    container.addView(layout);
    return layout;
}

From source file:com.android.contacts.activities.ActionBarAdapter.java

private void updateDisplayOptionsInner() {
    // All the flags we may change in this method.
    final int MASK = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP;

    // The current flags set to the action bar.  (only the ones that we may change here)
    final int current = mActionBar.getDisplayOptions() & MASK;

    final boolean isSearchOrSelectionMode = mSearchMode || mSelectionMode;

    // Build the new flags...
    int newFlags = 0;
    if (mShowHomeIcon && !isSearchOrSelectionMode) {
        newFlags |= ActionBar.DISPLAY_SHOW_HOME;
    }/*from ww  w.  ja va  2  s  .  c  o  m*/
    if (mSearchMode && !mSelectionMode) {
        // The search container is placed inside the toolbar. So we need to disable the
        // Toolbar's content inset in order to allow the search container to be the width of
        // the window.
        mToolbar.setContentInsetsRelative(0, mToolbar.getContentInsetEnd());
    }
    if (!isSearchOrSelectionMode) {
        newFlags |= ActionBar.DISPLAY_SHOW_TITLE;
        mToolbar.setContentInsetsRelative(mMaxToolbarContentInsetStart, mToolbar.getContentInsetEnd());
    }

    if (mSelectionMode) {
        // Minimize the horizontal width of the Toolbar since the selection container is placed
        // behind the toolbar and its left hand side needs to be clickable.
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mToolbar.getLayoutParams();
        params.width = LayoutParams.WRAP_CONTENT;
        params.gravity = Gravity.END;
        mToolbar.setLayoutParams(params);
    } else {
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mToolbar.getLayoutParams();
        params.width = LayoutParams.MATCH_PARENT;
        params.gravity = Gravity.END;
        mToolbar.setLayoutParams(params);
    }

    if (current != newFlags) {
        // Pass the mask here to preserve other flags that we're not interested here.
        mActionBar.setDisplayOptions(newFlags, MASK);
    }
}

From source file:de.spiritcroc.ownlog.ui.fragment.LogItemEditFragment.java

@Override
public boolean onLongClick(View view) {
    if (view == mEditTime) {
        int[] viewPos = new int[2];
        view.getLocationInWindow(viewPos);
        int[] offsetPos = new int[2];
        view.getRootView().findViewById(android.R.id.content).getLocationInWindow(offsetPos);
        Toast toast = Toast.makeText(getActivity(), view.getContentDescription(), Toast.LENGTH_SHORT);

        toast.setGravity(Gravity.END | Gravity.TOP, 0, viewPos[1] - offsetPos[1] + view.getHeight());
        toast.show();//from ww  w  . ja v a  2 s .c  om
        return true;
    }
    return false;
}

From source file:com.klinker.android.twitter.ui.MainActivity.java

@Override
public void onResume() {
    super.onResume();

    MainActivity.showIsRunning = false;//from w  ww.ja v a  2 s .  co m
    MainActivity.hideIsRunning = false;
    MainActivity.sendHandler.postDelayed(showSend, 1000);

    if (sharedPrefs.getBoolean("open_a_page", false)) {
        sharedPrefs.edit().putBoolean("open_a_page", false).commit();
        int page = sharedPrefs.getInt("open_what_page", 3);
        String title = "" + mSectionsPagerAdapter.getPageTitle(page);
        actionBar.setTitle(title);
        mViewPager.setCurrentItem(page);
    }

    if (sharedPrefs.getBoolean("open_interactions", false)) {
        sharedPrefs.edit().putBoolean("open_interactions", false).commit();
        mDrawerLayout.openDrawer(Gravity.END);
    }
}

From source file:com.lambdasoup.quickfit.ui.WorkoutListActivity.java

private void showSchedulesPane(long workoutId) {
    if (!isTwoPane) {
        Timber.wtf("showSchedulesPane called despite not in two-pane layout mode");
        return;// w w  w .ja  v  a  2s .  com
    }

    CoordinatorLayout.LayoutParams fabLayoutParams = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
    fabLayoutParams.setAnchorId(R.id.list_pane);
    fabLayoutParams.anchorGravity = Gravity.BOTTOM | Gravity.END;
    fabLayoutParams.gravity = Gravity.CENTER_HORIZONTAL;
    fab.setLayoutParams(fabLayoutParams);

    fab.setOnClickListener(view -> showMiniFabs());

    masterDetailView.requestShowDetail();

    SchedulesFragment newFragment = SchedulesFragment.create(workoutId);
    getSupportFragmentManager().beginTransaction().add(R.id.schedules_container, newFragment).commit();
}

From source file:com.htc.dotdesign.ToolBoxService.java

private void setToolPanelVisibility(boolean bShow) {
    if (mCurrExtend != null) {
        mWindowManager.removeView(mCurrExtend);
        mCurrExtend = null;/*  w  w w.ja v  a 2s .co  m*/
    }

    if (bShow) {
        mIsToolBarExtend = true;
        if (mCurrFun == FunType.Fun_Palette) {
            Resources res = getResources();
            WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            params.gravity = Gravity.START;
            if (mDragButtonParams.y < mScreenHeight / 2) {
                params.gravity = Gravity.TOP | params.gravity;
                params.y = mDragButtonParams.y + mDragButtonHeight;
                View top_arrow = mPalette.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.VISIBLE);
                View bottom_arrow = mPalette.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.GONE);
            } else {
                params.gravity = Gravity.BOTTOM | params.gravity;
                params.y = mScreenHeight - mDragButtonParams.y;
                View top_arrow = mPalette.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.GONE);
                View bottom_arrow = mPalette.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.VISIBLE);
            }
            int[] locations = new int[2];
            mBtnPalette.getLocationOnScreen(locations);
            int x = locations[0];
            params.x = (x + mBtnPalette.getWidth() / 2)
                    - (mArrowWidth / 2 + res.getDimensionPixelSize(R.dimen.h02));

            mPalette.setVisibility(View.VISIBLE);
            mWindowManager.addView(mPalette, params);
            mCurrExtend = mPalette;
            initBrushSize();
        } else if (mCurrFun == FunType.Fun_Eraser) {
            Resources res = getResources();
            WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            params.gravity = Gravity.START;
            if (mDragButtonParams.y < mScreenHeight / 2) {
                params.gravity = Gravity.TOP | params.gravity;
                params.y = mDragButtonParams.y + mDragButtonHeight;
                View top_arrow = mEraser.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.VISIBLE);
                View bottom_arrow = mEraser.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.GONE);
            } else {
                params.gravity = Gravity.BOTTOM | params.gravity;
                params.y = mScreenHeight - mDragButtonParams.y;
                View top_arrow = mEraser.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.GONE);
                View bottom_arrow = mEraser.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.VISIBLE);
            }
            int[] locations = new int[2];
            mBtnEraser.getLocationOnScreen(locations);
            int x = locations[0];
            params.x = (x + mBtnEraser.getWidth() / 2)
                    - (mArrowWidth / 2 + res.getDimensionPixelSize(R.dimen.h02));

            mEraser.setVisibility(View.VISIBLE);
            mWindowManager.addView(mEraser, params);
            mCurrExtend = mEraser;
            initBrushSize();
        } else if (mCurrFun == FunType.Fun_VirtualDot) {

        } else if (mCurrFun == FunType.Fun_Menu) {
            Resources res = getResources();
            WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            params.gravity = Gravity.END;
            if (mDragButtonParams.y < mScreenHeight / 2) {
                params.gravity = Gravity.TOP | params.gravity;
                params.y = mDragButtonParams.y + mDragButtonHeight;
                // Set top_arrow to visible and align to parent right.
                View top_arrow = mMenu.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.VISIBLE);
                LinearLayout.LayoutParams arrowParams = (LinearLayout.LayoutParams) top_arrow.getLayoutParams();
                arrowParams.setMarginEnd(res.getDimensionPixelSize(R.dimen.h02));
                arrowParams.gravity = Gravity.END;
                top_arrow.setLayoutParams(arrowParams);
                // Set bottom_arrow to gone
                View bottom_arrow = mMenu.findViewById(R.id.bottom_arrow);
                bottom_arrow.setVisibility(View.GONE);
            } else {
                params.gravity = Gravity.BOTTOM | params.gravity;
                params.y = mScreenHeight - mDragButtonParams.y;
                // Set top_arrow to gone
                View top_arrow = mMenu.findViewById(R.id.top_arrow);
                top_arrow.setVisibility(View.GONE);
                // Set bottom_arrow to visible and align to parent right.
                View bottom_arrow = mMenu.findViewById(R.id.bottom_arrow);
                LinearLayout.LayoutParams arrowParams = (LinearLayout.LayoutParams) bottom_arrow
                        .getLayoutParams();
                arrowParams.setMarginEnd(res.getDimensionPixelSize(R.dimen.h02));
                arrowParams.gravity = Gravity.END;
                bottom_arrow.setLayoutParams(arrowParams);
                bottom_arrow.setVisibility(View.VISIBLE);
            }
            int[] locations = new int[2];
            mBtnMenu.getLocationOnScreen(locations);
            int x = locations[0];
            //params.x = (x + mBtnMenu.getWidth()/2) - (mArrowWidth/2 + res.getDimensionPixelSize(R.dimen.h02));
            params.x = mScreenWidth - (x + mBtnMenu.getWidth() / 2)
                    - (mArrowWidth / 2 + res.getDimensionPixelSize(R.dimen.h02));

            mMenu.setVisibility(View.VISIBLE);
            mWindowManager.addView(mMenu, params);
            mCurrExtend = mMenu;
        }
    } else {
        mIsToolBarExtend = false;
    }

    updateToolBarFunIconColor();
}

From source file:co.carlosjimenez.android.currencyalerts.app.MainActivityFragment.java

/**
 * Method to set the position of the FAB button according to the material design guidelines.
 *///from  w ww . j a  va2 s.  c  o  m
private void addFloatingActionButton() {
    final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab);
    final int spacingDouble = getResources().getDimensionPixelSize(R.dimen.spacing_double);

    int bottomOfToolbar = mAppBarLayout.getBottom();

    final CoordinatorLayout.LayoutParams fabLayoutParams = new CoordinatorLayout.LayoutParams(fabSize, fabSize);
    fabLayoutParams.gravity = Gravity.END | Gravity.TOP;
    final int halfAFab = fabSize / 2;

    fabLayoutParams.setMargins(0, // left
            bottomOfToolbar - halfAFab, //top
            0, // right
            spacingDouble); // bottom
    MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, spacingDouble);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        // Account for the fab's emulated shadow.
        fabLayoutParams.topMargin -= (mCalculateButton.getPaddingTop() / 2);
    }
    mCoordinatorLayout.addView(mCalculateButton, fabLayoutParams);
}

From source file:org.catrobat.paintroid.MainActivity.java

@Override
public void onBackPressed() {
    if (!mToolbarIsVisible) {
        setFullScreen(false);//from   www  .  j a va2s. c  om
    } else if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
        drawerLayout.closeDrawer(Gravity.START);
    } else if (mLayerSideNav.isShown()) {
        drawerLayout.closeDrawer(Gravity.END);
    } else if (PaintroidApplication.currentTool.getToolOptionsAreShown()) {
        PaintroidApplication.currentTool.toggleShowToolOptions();
    } else if (PaintroidApplication.currentTool.getToolType() == ToolType.BRUSH) {
        showSecurityQuestionBeforeExit();
    } else {
        switchTool(ToolType.BRUSH);
    }
}

From source file:de.uni_weimar.mheinz.androidtouchscope.TouchScopeActivity.java

public void onHandClick(View view) {
    if (mLeftDrawer.getMenu().findItem(R.id.navigation_learner).isChecked()) {
        boolean isChecked = ((RadioButton) view).isChecked();
        switch (view.getId()) {
        case R.id.right_hand:
            if (isChecked)
                mLearningView.setGravity(Gravity.START);
            else//from w w w. j  av  a2  s.c om
                mLearningView.setGravity(Gravity.END);
            break;
        case R.id.left_hand:
            if (isChecked)
                mLearningView.setGravity(Gravity.END);
            else
                mLearningView.setGravity(Gravity.START);
            break;
        }
        mHostView.setTop(1); //forces a onSizeChange event
    }
}