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.wangdao.our.spread_2.widget_pull.LoadingLayout.java

public LoadingLayout(Context context, final PullToRefreshBase.Mode mode,
        final PullToRefreshBase.Orientation scrollDirection, TypedArray attrs) {
    super(context);
    mMode = mode;//from ww  w  .ja v a 2  s .  com
    mScrollDirection = scrollDirection;

    switch (scrollDirection) {
    case HORIZONTAL:
        LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_horizontal, this);
        break;
    case VERTICAL:
    default:
        LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, this);
        break;
    }

    mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner);
    mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text);
    mHeaderProgress = (ProgressBar) mInnerLayout.findViewById(R.id.pull_to_refresh_progress);
    mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text);
    mHeaderImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_image);
    LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams();

    switch (mode) {
    case PULL_FROM_END:
        lp.gravity = scrollDirection == PullToRefreshBase.Orientation.VERTICAL ? Gravity.TOP : Gravity.LEFT;

        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label);
        break;

    case PULL_FROM_START:
    default:
        lp.gravity = scrollDirection == PullToRefreshBase.Orientation.VERTICAL ? Gravity.BOTTOM : Gravity.RIGHT;

        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_release_label);
        break;
    }

    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
        Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
        if (null != background) {
            com.wangdao.our.spread_2.widget_pull.ViewCompat.setBackground(this, background);
        }
    }

    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance)) {
        TypedValue styleID = new TypedValue();
        attrs.getValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance, styleID);
        setTextAppearance(styleID.data);
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance)) {
        TypedValue styleID = new TypedValue();
        attrs.getValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID);
        setSubTextAppearance(styleID.data);
    }

    // Text Color attrs need to be set after TextAppearance attrs
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextColor)) {
        ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderTextColor);
        if (null != colors) {
            setTextColor(colors);
        }
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderSubTextColor)) {
        ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderSubTextColor);
        if (null != colors) {
            setSubTextColor(colors);
        }
    }

    // Try and get defined drawable from Attrs
    Drawable imageDrawable = null;
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawable)) {
        imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawable);
    }

    // Check Specific Drawable from Attrs, these overrite the generic
    // drawable attr above
    switch (mode) {
    case PULL_FROM_START:
    default:
        if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableStart)) {
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableStart);
        } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableTop)) {
            com.wangdao.our.spread_2.widget_pull.Utils.warnDeprecation("ptrDrawableTop", "ptrDrawableStart");
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableTop);
        }
        break;

    case PULL_FROM_END:
        if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableEnd)) {
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableEnd);
        } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableBottom)) {
            com.wangdao.our.spread_2.widget_pull.Utils.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd");
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableBottom);
        }
        break;
    }

    // If we don't have a user defined drawable, load the default
    if (null == imageDrawable) {
        imageDrawable = context.getResources().getDrawable(getDefaultDrawableResId());
    }

    // Set Drawable, and save width/height
    setLoadingDrawable(imageDrawable);

    reset();
}

From source file:com.facebook.notifications.internal.content.TextContent.java

@Override
public void applyTo(@NonNull View view) {
    if (view instanceof TextView) {
        TextView textView = (TextView) view;

        textView.setText(getText());//from  w  ww . jav  a2 s  .  c o  m
        textView.setTextColor(getTextColor());

        Typeface typeface = FontUtilities.parseFont(getTypeface());
        typeface = typeface != null ? typeface : Typeface.DEFAULT;

        textView.setTypeface(typeface);
        textView.setTextSize(getTypefaceSize());

        switch (getTextAlignment()) {
        case Left:
            textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
            break;

        case Center:
            textView.setGravity(Gravity.CENTER);
            break;

        case Right:
            textView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            break;
        }
    }
}

From source file:com.example.apple.assistapp.MainActivity.java

private void InitialDrawerLayout() {
    main_layout = (LinearLayout) findViewById(R.id.main_layout);
    drawer_left_layout = (LinearLayout) findViewById(R.id.drawer_left_layout);
    drawer_right_layout = (LinearLayout) findViewById(R.id.drawer_right_layout);

    DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) drawer_left_layout.getLayoutParams();
    params.width = draweropen_offset;//from   ww  w  .j  a v  a 2  s .c o  m
    drawer_left_layout.setLayoutParams(params);

    // drawer_left_layout.setId(0);
    // drawer_right_layout.setId(1);
    //
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerListener(new DrawerListener() {
        public void onDrawerClosed(View v) {
        }

        public void onDrawerOpened(View v) {
        }

        public void onDrawerSlide(View v, final float f) {
            int id = v.getId();
            if (id == R.id.drawer_left_layout) { // left
                main_layout.setX(draweropen_offset * f);
            }
        }

        public void onDrawerStateChanged(int arg0) {

        }
    });

    // Left Drawer
    drawer_left_layout.addView(getLeftDrawerLayout());
    // Right Drawer
    drawer_right_layout.addView(getRightDrawerLayout());
    //
    mDrawerLayout.setScrimColor(getResources().getColor(R.color.trans));
    mDrawerLayout.setDrawerShadow(getResources().getDrawable(R.drawable.drawer_shadow), Gravity.RIGHT);

}

From source file:des.calculator.ui.MenuTabActivity.java

private void buildHistoryTable() {
    final int historySize = state.getHistoryLength();

    TableRow currentRow = null;//w  w  w . j ava2 s .com
    // clear the table in case it has already been loaded.
    historyTable.removeAllViews();
    // for each history entry
    for (int i = historySize - 1; i >= 0; i--) {
        // create the new row
        currentRow = new TableRow(this);
        //TableLayout.LayoutParams rowLayout = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);

        //rowLayout.setMargins(2, 2, 2, 2);
        //currentRow.setLayoutParams(rowLayout);
        //currentRow.setBackgroundColor(0xFF282828);
        currentRow.setBackgroundResource(R.layout.rowlayout);
        historyTable.addView(currentRow,
                new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

        // add the history info
        TextView entry = new TextView(this);
        entry.setText(state.getInputHistory(i));
        entry.setGravity(Gravity.LEFT);
        entry.setTextSize(20);
        entry.setTextColor(0xFFFFFFFF);

        TextView answer = new TextView(this);
        answer.setText(state.getAnsHistory(i));
        answer.setGravity(Gravity.RIGHT);
        answer.setWidth(30);
        answer.setTextSize(20);
        answer.setTextColor(0xFFFFFFFF);

        // create layout params for the text views
        TableRow.LayoutParams textLayout = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        textLayout.setMargins(4, 1, 4, 1);

        currentRow.addView(entry, textLayout);
        currentRow.addView(answer, textLayout);
    }
}

From source file:com.ayoview.sample.textview.badge.ViewsFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.counter: {
        counterBadge.incrementBadgeCount(1);
        break;/* ww  w .ja  v  a2 s .  c om*/
    }

    case R.id.gravity: {
        gravityBadge.incrementBadgeCount(1);
        Log.d(getClass().getName(), String.valueOf(gravityBadge.getBadgeCount() % 9));
        if (gravityBadge.getBadgeCount() % 9 == 0) {
            gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.TOP);
        } else if (gravityBadge.getBadgeCount() % 9 == 1) {
            gravityBadge.setBadgeGravity(Gravity.RIGHT | Gravity.BOTTOM);
        } else if (gravityBadge.getBadgeCount() % 9 == 2) {
            gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM);
        } else if (gravityBadge.getBadgeCount() % 9 == 3) {
            gravityBadge.setBadgeGravity(Gravity.RIGHT | Gravity.TOP);
        } else if (gravityBadge.getBadgeCount() % 9 == 4) {
            gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        } else if (gravityBadge.getBadgeCount() % 9 == 5) {
            gravityBadge.setBadgeGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
        } else if (gravityBadge.getBadgeCount() % 9 == 6) {
            gravityBadge.setBadgeGravity(Gravity.CENTER);
        } else if (gravityBadge.getBadgeCount() % 9 == 7) {
            gravityBadge.setBadgeGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
        } else if (gravityBadge.getBadgeCount() % 9 == 8) {
            gravityBadge.setBadgeGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
        }
        break;
    }
    case R.id.visibility: {
        visibilityBadgeView
                .setVisibility(visibilityBadgeView.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
        break;
    }

    default:
        break;
    }

}

From source file:com.appsimobile.appsii.AbstractHotspotHelper.java

@SuppressWarnings("deprecation")
protected WindowManager.LayoutParams createHotspotParams(HotspotItem conf, SharedPreferences prefs) {

    Display display = mWindowManager.getDefaultDisplay();
    mHeight = display.getHeight();//  w w w .  j  a  v a2  s .co m

    float pct = conf.mHeightRelativeToViewHeight;
    int realHeight = (int) (mHeight * pct);
    if (realHeight < mDp56)
        realHeight = mDp56;

    int y = (int) (conf.mYPosRelativeToView * mHeight);

    int hotspotWidth = prefs.getInt("pref_hotspot_width", 22);

    int width = (int) (hotspotWidth * AppsiApplication.getDensity(mContext));

    int xOffset = 0;

    if (conf.mLeft) {
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                        | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                        | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.LEFT | Gravity.TOP;
        params.x = xOffset;
        params.y = y;
        params.width = width;
        params.height = realHeight;
        return params;
    } else {
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                        | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                        | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.RIGHT | Gravity.TOP;
        params.x = xOffset;
        params.y = y;
        params.width = width;
        params.height = realHeight;
        return params;
    }
}

From source file:foam.jellyfish.StarwispBuilder.java

public int BuildLayoutGravity(String p) {
    if (p.equals("centre"))
        return Gravity.CENTER;
    if (p.equals("left"))
        return Gravity.LEFT;
    if (p.equals("right"))
        return Gravity.RIGHT;
    if (p.equals("fill"))
        return Gravity.FILL;
    return Gravity.LEFT;
}

From source file:com.osc.tweet.app.activities.MainActivity.java

/**
 * Handler for {@link com.osc.tweet.events.OpenMyNoticesDrawerEvent}.
 *
 * @param e//w  w  w. java2s .c  om
 *       Event {@link com.osc.tweet.events.OpenMyNoticesDrawerEvent}.
 */
public void onEvent(OpenMyNoticesDrawerEvent e) {
    if (!mDrawerLayout.isDrawerOpen(Gravity.LEFT) && !mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
        mDrawerLayout.closeDrawer(Gravity.LEFT);
        mDrawerLayout.openDrawer(Gravity.RIGHT);
    }
}

From source file:be.ugent.zeus.hydra.views.ButtonBarLayout.java

private void setStacked(boolean stacked) {
    setOrientation(stacked ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
    setGravity(stacked ? Gravity.RIGHT : Gravity.BOTTOM);
    final View spacer = findViewById(android.support.v7.appcompat.R.id.spacer);
    if (spacer != null) {
        spacer.setVisibility(stacked ? View.GONE : View.INVISIBLE);
    }/*w w w .jav  a  2 s  . co m*/
    // Reverse the child order. This is specific to the Material button
    // bar's layout XML and will probably not generalize.
    final int childCount = getChildCount();
    for (int i = childCount - 2; i >= 0; i--) {
        bringChildToFront(getChildAt(i));
    }
}

From source file:com.nikola.despotoski.drawerlayoutedgetoggle.DrawerLayoutEdgeToggle.java

public DrawerLayoutEdgeToggle(Activity a, DrawerLayout l, int drawerOpen, int drawerClose,
        boolean keepShadowOnHandle, int drawerGravity) {

    if (drawerGravity != GravityCompat.END && drawerGravity != GravityCompat.START
            && drawerGravity != Gravity.LEFT && drawerGravity != Gravity.RIGHT)
        throw new IllegalArgumentException(
                "Use: GravityCompat.END, GravityCompat.START, Gravity.LEFT or Gravity.RIGHT for drawerGravity parameter");
    mGravity = drawerGravity;/*from   ww w.  j av  a 2s  .  c o  m*/
    mActivity = a;
    mDrawerLayout = l;
    mOpenDrawable = a.getResources().getDrawable(drawerOpen);
    mCloseDrawable = a.getResources().getDrawable(drawerClose);
    rootLayout = (FrameLayout) mActivity.findViewById(android.R.id.content);
    mHandle = new ImageView(a);
    final ViewTreeObserver viewTreeObserver = mHandle.getViewTreeObserver();
    if (viewTreeObserver.isAlive()) {
        viewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

            @SuppressLint("NewApi")
            @Override
            public void onGlobalLayout() {
                mDrawerLayout.measure(MeasureSpec.EXACTLY, MeasureSpec.EXACTLY);
                syncState();
                removeOnGlobalLayoutListener(mHandle, this);
            }
        });
    }

    mHandle.setOnClickListener(mHandleClickListenerInt);
    mHandle.setOnTouchListener(mHandleTouchListenerInt);
    mHandle.setSaveEnabled(true);
    mDrawerLayout.setOnTouchListener(mHandleTouchListenerInt);
    rootLayout.addView(mHandle,
            new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, drawerGravity));
    mKeepShadowOnHandle = keepShadowOnHandle;
    mCurrentDrawable = mCloseDrawable;
}