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:am.project.x.business.drawables.linedrawable.LineDrawableActivity.java

@SuppressLint("RtlHardcoded")
@Override//from w  ww.  ja v a  2  s  .  c  om
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (position) {
    default:
    case 0:
        drawable.setGravity(Gravity.BOTTOM);
        break;
    case 1:
        drawable.setGravity(Gravity.LEFT);
        break;
    case 2:
        drawable.setGravity(Gravity.TOP);
        break;
    case 3:
        drawable.setGravity(Gravity.RIGHT);
        break;
    case 4:
        drawable.setGravity(Gravity.CENTER_HORIZONTAL);
        break;
    case 5:
        drawable.setGravity(Gravity.CENTER_VERTICAL);
        break;
    case 6:
        drawable.setGravity(Gravity.TOP | Gravity.BOTTOM);
        break;
    case 7:
        drawable.setGravity(Gravity.LEFT | Gravity.RIGHT);
        break;
    }
}

From source file:biz.mosil.demo.navigationdrawer.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drw_layout);
    //  Drawer ?//from   w w  w.  j  av  a  2  s . co  m
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, //  Drawer Toggle ???
            R.drawable.ic_drawer, // Drawer  Icon
            R.string.open_left_drawer, // Drawer ??
            R.string.close_left_drawer // Drawer ??
    ) {
        // ??
        @Override
        public void onDrawerOpened(View drawerView) {
            //  Title 
            if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                getSupportActionBar().setTitle(R.string.open_right_drawer);
            } else {
                getSupportActionBar().setTitle(R.string.open_left_drawer);
            }

            if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                // ???
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
            } else {
                // ???
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT);
            }
        }

        // ??
        @Override
        public void onDrawerClosed(View drawerView) {
            if (mCurrentMenuItemPosition > -1) {
                getSupportActionBar().setTitle(MENU_ITEMS[mCurrentMenuItemPosition]);
            } else {
                //  Title  APP ??
                getSupportActionBar().setTitle(R.string.app_name);
            }

            if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                // 
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
            } else if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                // ?
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
            } else {
                // ?
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
            }
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    //  Up Button (? Logo )
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    //  Up Button 
    getSupportActionBar().setHomeButtonEnabled(true);

    setDrawerMenu();
}

From source file:am.project.x.business.drawables.combinationdrawable.CombinationDrawableActivity.java

@SuppressLint("RtlHardcoded")
@Override//www  .  j a  va2s  . c om
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (position) {
    default:
    case 0:
        drawable.setGravity(Gravity.CENTER);
        break;
    case 1:
        drawable.setGravity(Gravity.LEFT);
        break;
    case 2:
        drawable.setGravity(Gravity.CENTER_HORIZONTAL);
        break;
    case 3:
        drawable.setGravity(Gravity.RIGHT);
        break;
    case 4:
        drawable.setGravity(Gravity.CENTER_VERTICAL);
        break;
    case 5:
        drawable.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
        break;
    case 6:
        drawable.setGravity(Gravity.BOTTOM);
        break;
    case 7:
        drawable.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
        break;
    case 8:
        drawable.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
        break;
    }
}

From source file:co.lemonlabs.android.slidingdebugmenu.SlidingDebugMenu.java

public SlidingDebugMenu(Context context, AttributeSet attrs) {
    super(context, attrs);
    mModules = new ArrayList<>();
    mModuleViews = new HashMap<>();

    DrawerLayout.LayoutParams params = new DrawerLayout.LayoutParams(context, attrs);
    params.gravity = Gravity.RIGHT;
    setLayoutParams(params);// ww  w  .j ava 2 s .c om
}

From source file:de.escoand.readdaily.MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // theme/*from   w w  w .  j a v a2 s.co  m*/
    PreferenceManager.setDefaultValues(this, R.xml.settings, false);
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("readability", false))
        setTheme(R.style.AppTheme_Readability);
    setContentView(R.layout.activity_drawer);

    // drawer
    layout = (DrawerLayout) findViewById(R.id.wrapper);
    ((NavigationView) findViewById(R.id.drawer)).setNavigationItemSelectedListener(this);
    layout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);

    // toolbars
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbarRight = (Toolbar) findViewById(R.id.toolbar_right);
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            layout.openDrawer(Gravity.LEFT);
        }
    });
    toolbarRight.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            layout.closeDrawer(Gravity.RIGHT);
        }
    });
    playerButton = toolbar.findViewById(R.id.toolbar_player);
    searchButton = (SearchView) toolbar.findViewById(R.id.toolbar_search);

    // search
    // ToDo make search work again
    ((SearchView) toolbar.findViewById(R.id.toolbar_search)).setOnQueryTextListener(new OnSearchListener());

    // fragments
    handler.addDateListener(this);
    handler.addDateListener((OnDateSelectedListener) findViewById(R.id.content_pager));
    handler.addDateListener(
            (OnDateSelectedListener) getSupportFragmentManager().findFragmentById(R.id.content_voty));
    handler.addDateListener(
            (OnDateSelectedListener) getSupportFragmentManager().findFragmentById(R.id.content_intro));
    handler.addDateListener(
            (OnDateSelectedListener) getSupportFragmentManager().findFragmentById(R.id.content_footer));

    // floating buttons
    if (findViewById(R.id.button_more) != null)
        findViewById(R.id.button_more).setOnClickListener(new OnMoreClickListener());
    if (findViewById(R.id.button_intro) != null)
        findViewById(R.id.button_intro).setOnClickListener(new OnIntroClickListener());
    if (findViewById(R.id.button_voty) != null)
        findViewById(R.id.button_voty).setOnClickListener(new OnVotyClickListener());

    // registration
    PushInstanceService.doRegistration(this, true);

    // start store if no data
    if (!Database.getInstance(this).isAnyInstalled())
        startActivity(new Intent(getApplication(), StoreActivity.class));
}

From source file:com.readystatesoftware.ghostlog.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Switch mainSwitch = new Switch(this);
    mainSwitch.setChecked(LogService.isRunning());
    mainSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override//  ww  w.j a v a  2  s .c om
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            Intent intent = new Intent(MainActivity.this, LogService.class);
            if (b) {
                if (!LogService.isRunning()) {
                    startService(intent);
                }
            } else {
                stopService(intent);
            }
        }
    });

    final ActionBar bar = getActionBar();
    final ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
    lp.rightMargin = getResources().getDimensionPixelSize(R.dimen.main_switch_margin_right);
    bar.setCustomView(mainSwitch, lp);
    bar.setDisplayShowCustomEnabled(true);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (!mPrefs.getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, false)) {
        PreferenceManager.setDefaultValues(this, R.xml.pref_filters, true);
        PreferenceManager.setDefaultValues(this, R.xml.pref_appearance, true);
        SharedPreferences.Editor edit = mPrefs.edit();
        edit.putBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, true);
        edit.apply();
    }

}

From source file:com.libs.drawerlayouttoggles.ContentDisplaceDrawerToggle.java

@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
    getDrawerMinusShadow();// www  .j  a v a  2s.  c  om
    float translationX = mMinusShadow * slideOffset;
    translationX = mGravity == GravityCompat.START || mGravity == Gravity.RIGHT ? translationX
            : mScreenWidth - translationX;
    updateContentMoved(translationX);

}

From source file:com.mifos.utils.DataTableUIBuilder.java

public LinearLayout getDataTableLayout(final DataTable dataTable, JsonArray jsonElements,
        LinearLayout parentLayout, final Context context, final int entityId,
        DataTableActionListener mListener) {
    dataTableActionListener = mListener;

    /**//from   ww w .ja v  a 2  s. co m
     * Create a Iterator with Json Elements to Iterate over the DataTable
     * Response.
     */
    Iterator<JsonElement> jsonElementIterator = jsonElements.iterator();
    /*
     * Each Row of the Data Table is Treated as a Table Here.
     * Creating the First Table for First Row
     */
    tableIndex = 0;
    while (jsonElementIterator.hasNext()) {
        TableLayout tableLayout = new TableLayout(context);
        tableLayout.setPadding(10, 10, 10, 10);

        final JsonElement jsonElement = jsonElementIterator.next();
        /*
        * Each Entry in a Data Table is Displayed in the
        * form of a table where each row contains one Key-Value Pair
        * i.e a Column Name - Column Value from the DataTable
        */
        int rowIndex = 0;
        while (rowIndex < dataTable.getColumnHeaderData().size()) {
            TableRow tableRow = new TableRow(context);
            tableRow.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
            tableRow.setPadding(10, 10, 10, 10);
            if (rowIndex % 2 == 0) {
                tableRow.setBackgroundColor(Color.LTGRAY);
            } else {
                tableRow.setBackgroundColor(Color.WHITE);
            }

            TextView key = new TextView(context);
            key.setText(dataTable.getColumnHeaderData().get(rowIndex).getColumnName());
            key.setGravity(Gravity.LEFT);
            TextView value = new TextView(context);
            value.setGravity(Gravity.RIGHT);
            if (jsonElement.getAsJsonObject().get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName())
                    .toString().contains("\"")) {
                value.setText(jsonElement.getAsJsonObject()
                        .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString()
                        .replace("\"", ""));
            } else {
                value.setText(jsonElement.getAsJsonObject()
                        .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString());
            }

            tableRow.addView(key, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tableRow.addView(value, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
            layoutParams.setMargins(12, 16, 12, 16);
            tableLayout.addView(tableRow, layoutParams);

            rowIndex++;
        }

        tableLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Toast.makeText(context, "Update Row " + tableIndex, Toast.LENGTH_SHORT).show();
            }
        });

        tableLayout.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {

                Toast.makeText(context, "Deleting Row " + tableIndex, Toast.LENGTH_SHORT).show();

                BaseApiManager baseApiManager = new BaseApiManager();
                DataManager dataManager = new DataManager(baseApiManager);
                Observable<GenericResponse> call = dataManager
                        .removeDataTableEntry(dataTable.getRegisteredTableName(), entityId,
                                Integer.parseInt(jsonElement.getAsJsonObject()
                                        .get(dataTable.getColumnHeaderData().get(0).getColumnName())
                                        .toString()));
                Subscription subscription = call.subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<GenericResponse>() {
                            @Override
                            public void onCompleted() {

                            }

                            @Override
                            public void onError(Throwable e) {

                            }

                            @Override
                            public void onNext(GenericResponse genericResponse) {
                                Toast.makeText(context, "Deleted Row " + tableIndex, Toast.LENGTH_SHORT).show();
                                dataTableActionListener.onRowDeleted();
                            }
                        });

                return true;
            }
        });

        View v = new View(context);
        v.setBackgroundColor(ContextCompat.getColor(context, R.color.black));
        parentLayout.addView(tableLayout);
        parentLayout.addView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 5));
        Log.i("TABLE INDEX", "" + tableIndex);
        tableIndex++;
    }
    return parentLayout;
}

From source file:com.apprevelations.Cozzy.FoldingDrawerLayout.java

boolean isDrawerView2(View child) {
    final int gravity = ((LayoutParams) child.getLayoutParams()).gravity;
    final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(child));
    return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0;
}

From source file:com.brookmanholmes.bma.wizard.ui.StepPagerStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (pageCount == 0) {
        return;/*  ww w  . j a  v a  2 s.com*/
    }

    float totalWidth = pageCount * (tabWidth + indicatorSpacing) - indicatorSpacing;
    float totalcx;
    float cy;
    boolean fillHorizontal = false;

    switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        totalcx = (getWidth() - totalWidth) / 2;
        break;
    case Gravity.RIGHT:
        totalcx = getWidth() - getPaddingRight() - totalWidth;
        break;
    case Gravity.FILL_HORIZONTAL:
        totalcx = getPaddingLeft();
        fillHorizontal = true;
        break;
    default:
        totalcx = getPaddingLeft();
    }

    switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.CENTER_VERTICAL:
        cy = (int) (getHeight() - tabHeight) / 2;
        break;
    case Gravity.BOTTOM:
        cy = getHeight() - getPaddingBottom() - tabHeight;
        break;
    default:
        cy = getPaddingTop();
    }

    float center = cy + tabHeight / 2;

    float tabWidth = this.tabWidth;
    if (fillHorizontal) {
        tabWidth = (getWidth() - getPaddingRight() - getPaddingLeft() - (pageCount - 1) * indicatorSpacing)
                / pageCount;
    }

    for (int i = 0; i < pageCount; i++) {
        float cx = totalcx + (i * (tabWidth + indicatorSpacing));

        Paint tempPaint;

        if (i < currentPage)
            tempPaint = prevTabPaint;
        else if (i > currentPage)
            tempPaint = nextTabPaint;
        else
            tempPaint = selectedTabPaint;

        canvas.drawCircle(cx, center, i == currentPage ? radius : nonCurrentRadius, tempPaint);
    }
}