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.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout.java

public void setDrawerLockMode(int lockMode, int gravity) {
    if (gravity == Gravity.LEFT)
        setDrawerLockMode(lockMode, mLeftDrawer);
    else if (gravity == Gravity.RIGHT)
        setDrawerLockMode(lockMode, mRightDrawer);
    else/*  w  w w  . j  a  va 2s  . c o  m*/
        throw new IllegalArgumentException("gravity must be Gravity.LEFT or Gravity.RIGHT");
}

From source file:com.facebook.android.friendsmash.ScoreboardFragment.java

private void populateScoreboard() {
    // Ensure all components are firstly removed from scoreboardContainer
    scoreboardContainer.removeAllViews();

    // Ensure the progress spinner is hidden
    progressContainer.setVisibility(View.INVISIBLE);

    // Ensure scoreboardEntriesList is not null and not empty first
    if (application.getScoreboardEntriesList() == null || application.getScoreboardEntriesList().size() <= 0) {
        closeAndShowError(getResources().getString(R.string.error_no_scores));
    } else {//from  w w  w .j ava2 s.  co m
        // Iterate through scoreboardEntriesList, creating new UI elements for each entry
        int index = 0;
        Iterator<ScoreboardEntry> scoreboardEntriesIterator = application.getScoreboardEntriesList().iterator();
        while (scoreboardEntriesIterator.hasNext()) {
            // Get the current scoreboard entry
            final ScoreboardEntry currentScoreboardEntry = scoreboardEntriesIterator.next();

            // FrameLayout Container for the currentScoreboardEntry ...

            // Create and add a new FrameLayout to display the details of this entry
            FrameLayout frameLayout = new FrameLayout(getActivity());
            scoreboardContainer.addView(frameLayout);

            // Set the attributes for this frameLayout
            int topPadding = getResources().getDimensionPixelSize(R.dimen.scoreboard_entry_top_margin);
            frameLayout.setPadding(0, topPadding, 0, 0);

            // ImageView background image ...
            {
                // Create and add an ImageView for the background image to this entry
                ImageView backgroundImageView = new ImageView(getActivity());
                frameLayout.addView(backgroundImageView);

                // Set the image of the backgroundImageView
                String uri = "drawable/scores_stub_even";
                if (index % 2 != 0) {
                    // Odd entry
                    uri = "drawable/scores_stub_odd";
                }
                int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName());
                Drawable image = getResources().getDrawable(imageResource);
                backgroundImageView.setImageDrawable(image);

                // Other attributes of backgroundImageView to modify
                FrameLayout.LayoutParams backgroundImageViewLayoutParams = new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
                int backgroundImageViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_background_imageview_margin_top);
                backgroundImageViewLayoutParams.setMargins(0, backgroundImageViewMarginTop, 0, 0);
                backgroundImageViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    backgroundImageViewLayoutParams.gravity = Gravity.RIGHT;
                }
                backgroundImageView.setLayoutParams(backgroundImageViewLayoutParams);
            }

            // ProfilePictureView of the current user ...
            {
                // Create and add a ProfilePictureView for the current user entry's profile picture
                ProfilePictureView profilePictureView = new ProfilePictureView(getActivity());
                frameLayout.addView(profilePictureView);

                // Set the attributes of the profilePictureView
                int profilePictureViewWidth = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_width);
                FrameLayout.LayoutParams profilePictureViewLayoutParams = new FrameLayout.LayoutParams(
                        profilePictureViewWidth, profilePictureViewWidth);
                int profilePictureViewMarginLeft = 0;
                int profilePictureViewMarginTop = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_top);
                int profilePictureViewMarginRight = 0;
                int profilePictureViewMarginBottom = 0;
                if (index % 2 == 0) {
                    profilePictureViewMarginLeft = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_left);
                } else {
                    profilePictureViewMarginRight = getResources()
                            .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_right);
                }
                profilePictureViewLayoutParams.setMargins(profilePictureViewMarginLeft,
                        profilePictureViewMarginTop, profilePictureViewMarginRight,
                        profilePictureViewMarginBottom);
                profilePictureViewLayoutParams.gravity = Gravity.LEFT;
                if (index % 2 != 0) {
                    // Odd entry
                    profilePictureViewLayoutParams.gravity = Gravity.RIGHT;
                }
                profilePictureView.setLayoutParams(profilePictureViewLayoutParams);

                // Finally set the id of the user to show their profile pic
                profilePictureView.setProfileId(currentScoreboardEntry.getId());
            }

            // LinearLayout to hold the text in this entry

            // Create and add a LinearLayout to hold the TextViews
            LinearLayout textViewsLinearLayout = new LinearLayout(getActivity());
            frameLayout.addView(textViewsLinearLayout);

            // Set the attributes for this textViewsLinearLayout
            FrameLayout.LayoutParams textViewsLinearLayoutLayoutParams = new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
            int textViewsLinearLayoutMarginLeft = 0;
            int textViewsLinearLayoutMarginTop = getResources()
                    .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_top);
            int textViewsLinearLayoutMarginRight = 0;
            int textViewsLinearLayoutMarginBottom = 0;
            if (index % 2 == 0) {
                textViewsLinearLayoutMarginLeft = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_left);
            } else {
                textViewsLinearLayoutMarginRight = getResources()
                        .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_right);
            }
            textViewsLinearLayoutLayoutParams.setMargins(textViewsLinearLayoutMarginLeft,
                    textViewsLinearLayoutMarginTop, textViewsLinearLayoutMarginRight,
                    textViewsLinearLayoutMarginBottom);
            textViewsLinearLayoutLayoutParams.gravity = Gravity.LEFT;
            if (index % 2 != 0) {
                // Odd entry
                textViewsLinearLayoutLayoutParams.gravity = Gravity.RIGHT;
            }
            textViewsLinearLayout.setLayoutParams(textViewsLinearLayoutLayoutParams);
            textViewsLinearLayout.setOrientation(LinearLayout.VERTICAL);

            // TextView with the position and name of the current user
            {
                // Set the text that should go in this TextView first
                int position = index + 1;
                String currentScoreboardEntryTitle = position + ". " + currentScoreboardEntry.getName();

                // Create and add a TextView for the current user position and first name
                TextView titleTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(titleTextView);

                // Set the text and other attributes for this TextView
                titleTextView.setText(currentScoreboardEntryTitle);
                titleTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerNameFont);
            }

            // TextView with the score of the current user
            {
                // Create and add a TextView for the current user score
                TextView scoreTextView = new TextView(getActivity());
                textViewsLinearLayout.addView(scoreTextView);

                // Set the text and other attributes for this TextView
                scoreTextView.setText("Score: " + currentScoreboardEntry.getScore());
                scoreTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerScoreFont);
            }

            // Finally make this frameLayout clickable so that a game starts with the user smashing
            // the user represented by this frameLayout in the scoreContainer
            frameLayout.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_UP) {
                        Bundle bundle = new Bundle();
                        bundle.putString("user_id", currentScoreboardEntry.getId());

                        Intent i = new Intent();
                        i.putExtras(bundle);

                        getActivity().setResult(Activity.RESULT_FIRST_USER, i);
                        getActivity().finish();
                        return false;
                    } else {
                        return true;
                    }
                }

            });

            // Increment the index before looping back
            index++;
        }
    }
}

From source file:com.hippo.drawerlayout.DrawerLayout.java

public boolean isDrawerOpen(int gravity) {
    if (gravity == Gravity.LEFT) {
        return isDrawerOpen(mLeftDrawer);
    } else if (gravity == Gravity.RIGHT) {
        return isDrawerOpen(mRightDrawer);
    } else {/*from  ww w  .ja v  a  2 s  .c o m*/
        throw new IllegalArgumentException("gravity must be Gravity.LEFT or Gravity.RIGHT");
    }
}

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

private void guideCollections() {
    Activity activity = getActivity2();// ww  w .  ja v a  2  s.c  o m
    if (null == activity || !Settings.getGuideCollections()) {
        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_collections_title).setContentText(R.string.guide_collections_text)
            .replaceEndButton(R.layout.button_guide)
            .setShowcaseEventListener(new SimpleShowcaseEventListener() {
                @Override
                public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
                    mShowcaseView = null;
                    ViewUtils.removeFromParent(showcaseView);
                    Settings.putGuideCollections(false);
                    openDrawer(Gravity.RIGHT);
                }
            }).build();
}

From source file:com.dldzkj.app.renxing.MainActivity.java

private void initDrawLayoutEvents() {
    mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override//from  w ww  .  j a v  a 2  s. c  om
        public void onDrawerStateChanged(int newState) {
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            View mContent = mDrawerLayout.getChildAt(0);
            View mMenu = drawerView;
            float scale = 1 - slideOffset;
            //                float rightScale = 0.8f + scale * 0.2f;

            if (drawerView.getTag().equals("LEFT")) {
                /* ??
                 float leftScale = 1 - 0.3f * scale;
                 mMenu.setScaleX(leftScale);
                 mMenu.setScaleY(leftScale);*/
                mMenu.setAlpha(0.6f + 0.4f * (1 - scale));
                mContent.setTranslationX(mMenu.getMeasuredWidth() * (1 - scale));
                /* mContent.setPivotX(0);
                 mContent.setPivotY(mContent.getMeasuredHeight() / 2);
                 mContent.invalidate();
                 mContent.setScaleX(rightScale);
                 mContent.setScaleY(rightScale);*/
            } else {
                mContent.setTranslationX(-mMenu.getMeasuredWidth() * slideOffset);
                /* mContent.setPivotX(mContent.getMeasuredWidth());
                 mContent.setPivotY(mContent.getMeasuredHeight() / 2);
                 mContent.invalidate();
                 mContent.setScaleX(rightScale);
                 mContent.setScaleY(rightScale);*/
            }

        }

        @Override
        public void onDrawerOpened(View drawerView) {
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
        }
    });
}

From source file:com.wecandoit.jinju_0_0_4.jActivity_YoutubeSearchList.java

/**
 * Sets up the layout programatically for the three different states.
 * Portrait, landscape or fullscreen+landscape. This has to be done
 * programmatically because we handle the orientation changes ourselves in
 * order to get fluent fullscreen transitions, so the xml layout resources
 * do not get reloaded.//from   ww  w.  j av a2 s  .c o m
 */
private void layout() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    mVideoListFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE);
    mVideoListFragment.setLabelVisibility(isPortrait);
    mCloseButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);
    //mFavoriteButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);
    //mDownloadButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);

    if (isFullscreen) {
        mVideoBox.setTranslationY(0); // Reset any translation that was
        // applied in portrait.
        setLayoutSize(mVideoFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSizeAndGravity(mVideoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT);
    } else if (isPortrait) {
        setLayoutSize(mVideoListFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSizeAndGravity(mVideoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM);
        setLayoutSize(mVideoFragment.getView(), MATCH_PARENT, WRAP_CONTENT);
    } else {
        mVideoBox.setTranslationY(0); // Reset any translation that was
        // applied in portrait.
        int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp);
        setLayoutSize(mVideoListFragment.getView(), screenWidth / 4, MATCH_PARENT);
        int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP);
        setLayoutSize(mVideoFragment.getView(), videoWidth, WRAP_CONTENT);
        setLayoutSizeAndGravity(mVideoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    }
}

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  w w.  j a  v a 2s  .com
 * @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.hippo.drawerlayout.DrawerLayout.java

public void setDrawerShadow(Drawable shadowDrawable, int gravity) {
    switch (gravity) {
    case Gravity.LEFT:
        mShadow.setShadowLeft(shadowDrawable);
        break;// ww w .j  a v  a 2  s  .  c o m
    case Gravity.RIGHT:
        mShadow.setShadowRight(shadowDrawable);
        break;
    default:
        throw new IllegalStateException("setDrawerShadow only support Gravity.LEFT and Gravity.RIGHT");
    }
    invalidate();
}

From source file:com.vuze.android.remote.activity.TorrentViewActivity.java

private void setupActionBar() {
    Toolbar abToolBar = (Toolbar) findViewById(R.id.actionbar);
    try {//from w ww.ja  v  a2  s.c o  m
        setSupportActionBar(abToolBar);
    } catch (NullPointerException ignore) {
        //setSupportActionBar says it can be nullable, but on Android TV API 22,
        // appcompat 23.1.1:
        //      Caused by: java.lang.NullPointerException: Attempt to invoke
        // virtual method 'java.lang.CharSequence android.support.v7.widget
        // .Toolbar.getTitle()' on a null object reference
        //      at android.support.v7.widget.ToolbarWidgetWrapper.<init>
        // (ToolbarWidgetWrapper.java:98)
        //      at android.support.v7.widget.ToolbarWidgetWrapper.<init>
        // (ToolbarWidgetWrapper.java:91)
        //      at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar
        // .java:73)
        //      at android.support.v7.app.AppCompatDelegateImplV7
        // .setSupportActionBar(AppCompatDelegateImplV7.java:205)
        //      at android.support.v7.app.AppCompatActivity.setSupportActionBar
        // (AppCompatActivity.java:99)
    }
    if (abToolBar == null) {
        if (DEBUG) {
            System.err.println("toolBar is null");
        }
        return;
    }

    View toolbarSubView = findViewById(R.id.actionbar_subview);
    if (toolbarSubView != null) {
        // Hack to make view go to the right on the toolbar
        // from http://stackoverflow
        // .com/questions/26510000/how-can-i-place-a-progressbar-at-the-right-of
        // -the-toolbar
        Toolbar.LayoutParams layoutParams = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.RIGHT);
        toolbarSubView.setLayoutParams(layoutParams);
    }

    ActionBar actionBar = getSupportActionBar();
    if (actionBar == null) {
        if (DEBUG) {
            System.err.println("actionBar is null");
        }
        return;
    }
    actionBar.setDisplayHomeAsUpEnabled(true);
}

From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.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. DrawerLayout 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}.
 */// w  ww  .java 2  s .  co m
public void setDrawerLockMode(int lockMode) {
    setDrawerLockMode(lockMode, Gravity.LEFT);
    setDrawerLockMode(lockMode, Gravity.RIGHT);
}