Example usage for android.view Gravity START

List of usage examples for android.view Gravity START

Introduction

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

Prototype

int START

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

Click Source Link

Document

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

Usage

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

@Override
public void setNavigationMode(int mode) {
    final int oldMode = mNavigationMode;
    if (mode != oldMode) {
        switch (oldMode) {
        case ActionBar.NAVIGATION_MODE_LIST:
            if (mSpinner != null && mSpinner.getParent() == mToolbar) {
                mToolbar.removeView(mSpinner);
            }/*from   w  w  w .  j a  va  2s. co m*/
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabView != null && mTabView.getParent() == mToolbar) {
                mToolbar.removeView(mTabView);
            }
            break;
        }

        mNavigationMode = mode;

        switch (mode) {
        case ActionBar.NAVIGATION_MODE_STANDARD:
            break;
        case ActionBar.NAVIGATION_MODE_LIST:
            ensureSpinner();
            mToolbar.addView(mSpinner, 0);
            break;
        case ActionBar.NAVIGATION_MODE_TABS:
            if (mTabView != null) {
                mToolbar.addView(mTabView, 0);
                Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams();
                lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
                lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
                lp.gravity = Gravity.START | Gravity.BOTTOM;
            }
            break;
        default:
            throw new IllegalArgumentException("Invalid navigation mode " + mode);
        }
    }
}

From source file:android.support.v7ox.widget.ToolbarWidgetWrapper.java

private void ensureSpinner() {
    if (mSpinner == null) {
        mSpinner = new AppCompatSpinner(getContext(), null, R.attr.actionDropDownStyle_ox);
        Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
        mSpinner.setLayoutParams(lp);//from  w w  w . j  a  v a  2  s.c  om
    }
}

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

private int getGravity(int gravity) {
    if (gravity == -1)
        return -1;

    int realGravityValue;

    switch (gravity) {
    case 0://from w  w w .j a  v a  2  s. c  o  m
        realGravityValue = Gravity.START;
        break;
    case 1:
        realGravityValue = Gravity.CENTER_HORIZONTAL;
        break;
    case 2:
        realGravityValue = Gravity.END;
        break;
    default:
        throw new IllegalArgumentException("Invalid value " + "specified for swipe_descriptionGravity. "
                + "Use \"left\", \"center\", \"right\" or leave " + "blank for default.");
    }

    return realGravityValue;
}

From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private WindowManager.LayoutParams createFilterLayoutParams() {
    WindowManager.LayoutParams wlp = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
            mScreenManager.getScreenHeight(), 0, -mScreenManager.getStatusBarHeightPx(),
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                    | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
            PixelFormat.TRANSLUCENT);/*from  ww  w.  j  a va2 s .c om*/

    wlp.gravity = Gravity.TOP | Gravity.START;
    wlp.buttonBrightness = mSettingsModel.getDimButtonsFlag() ? 0 : -1;

    return wlp;
}

From source file:com.alirezaafkar.toolbar.ToolbarWidgetWrapper.java

private void ensureSpinner() {
    if (mSpinner == null) {
        mSpinner = new AppCompatSpinner(getContext(), null, R.attr.actionDropDownStyle);
        RtlToolbar.LayoutParams lp = new RtlToolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
        mSpinner.setLayoutParams(lp);//w  ww.  j av a 2 s. co  m
    }
}

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

private void ensureSpinner() {
    if (mSpinner == null) {
        mSpinner = new SpinnerCompat(getContext(), null, R.attr.actionDropDownStyle);
        Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
        mSpinner.setLayoutParams(lp);/* w  ww . j  ava2  s .c  o  m*/
    }
}

From source file:com.saarang.samples.apps.iosched.ui.BaseActivity.java

/**
 * Sets up the navigation drawer as appropriate. Note that the nav drawer will be
 * different depending on whether the attendee indicated that they are attending the
 * event on-site vs. attending remotely.
 *//*w ww . ja  va 2  s.  com*/
private void setupNavDrawer() {
    // What nav drawer item should be selected?
    int selfItem = getSelfNavDrawerItem();

    mDrawerLayout = (DrawerLayout) findViewById(com.saarang.samples.apps.iosched.R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    mDrawerLayout.setStatusBarBackgroundColor(
            getResources().getColor(com.saarang.samples.apps.iosched.R.color.theme_primary_dark));
    ScrimInsetsScrollView navDrawer = (ScrimInsetsScrollView) mDrawerLayout
            .findViewById(com.saarang.samples.apps.iosched.R.id.navdrawer);
    if (selfItem == NAVDRAWER_ITEM_INVALID) {
        // do not show a nav drawer
        if (navDrawer != null) {
            ((ViewGroup) navDrawer.getParent()).removeView(navDrawer);
        }
        mDrawerLayout = null;
        return;
    }

    if (navDrawer != null) {
        final View chosenAccountContentView = findViewById(
                com.saarang.samples.apps.iosched.R.id.chosen_account_content_view);
        final View chosenAccountView = findViewById(com.saarang.samples.apps.iosched.R.id.chosen_account_view);
        final int navDrawerChosenAccountHeight = getResources().getDimensionPixelSize(
                com.saarang.samples.apps.iosched.R.dimen.navdrawer_chosen_account_height);
        navDrawer.setOnInsetsCallback(new ScrimInsetsScrollView.OnInsetsCallback() {
            @Override
            public void onInsetsChanged(Rect insets) {
                ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chosenAccountContentView
                        .getLayoutParams();
                lp.topMargin = insets.top;
                chosenAccountContentView.setLayoutParams(lp);

                ViewGroup.LayoutParams lp2 = chosenAccountView.getLayoutParams();
                lp2.height = navDrawerChosenAccountHeight + insets.top;
                chosenAccountView.setLayoutParams(lp2);
            }
        });
    }

    if (mActionBarToolbar != null) {
        mActionBarToolbar.setNavigationIcon(com.saarang.samples.apps.iosched.R.drawable.ic_drawer);
        mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawerLayout.openDrawer(Gravity.START);
            }
        });
    }

    mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            // run deferred action, if we have one
            if (mDeferredOnDrawerClosedRunnable != null) {
                mDeferredOnDrawerClosedRunnable.run();
                mDeferredOnDrawerClosedRunnable = null;
            }
            if (mAccountBoxExpanded) {
                mAccountBoxExpanded = false;
                setupAccountBoxToggle();
            }
            onNavDrawerStateChanged(false, false);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            onNavDrawerStateChanged(true, false);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            onNavDrawerSlide(slideOffset);
        }
    });

    mDrawerLayout.setDrawerShadow(com.saarang.samples.apps.iosched.R.drawable.drawer_shadow, Gravity.START);

    // populate the nav drawer with the correct items
    populateNavDrawer();

    // When the user runs the app for the first time, we want to land them with the
    // navigation drawer open. But just the first time.
    if (!PrefUtils.isWelcomeDone(this)) {
        // first run of the app starts with the nav drawer open
        PrefUtils.markWelcomeDone(this);
        mDrawerLayout.openDrawer(Gravity.START);
    }
}

From source file:ti.modules.titanium.ui.widget.TiUIDrawerLayout.java

@Override
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) {

    if (key.equals(TiC.PROPERTY_LEFT_VIEW)) {
        if (newValue == null || newValue == this.leftView) {
            return;
        }//from  www  .  ja  va  2  s  .  co m
        TiViewProxy newProxy = null;
        int index = 0;
        if (this.leftView != null) {
            index = this.leftFrame.indexOfChild(this.leftView.getOrCreateView().getNativeView());
        }
        if (newValue instanceof TiViewProxy) {
            if (newValue instanceof WindowProxy) {
                throw new IllegalStateException("cannot add window as a child view of other window");
            }
            newProxy = (TiViewProxy) newValue;
            initLeft();
            this.leftFrame.addView(newProxy.getOrCreateView().getOuterView(), index);
        } else {
            Log.e(TAG, "invalid type for leftView");
        }
        if (this.leftView != null) {
            this.leftFrame.removeView(this.leftView.getOrCreateView().getNativeView());
        }
        this.leftView = newProxy;

    } else if (key.equals(TiC.PROPERTY_RIGHT_VIEW)) {
        if (newValue == null || newValue == this.rightView) {
            return;
        }
        TiViewProxy newProxy = null;
        int index = 0;
        if (this.rightView != null) {
            index = this.rightFrame.indexOfChild(this.rightView.getOrCreateView().getNativeView());
        }
        if (newValue instanceof TiViewProxy) {
            if (newValue instanceof WindowProxy) {
                throw new IllegalStateException("cannot add window as a child view of other window");
            }
            newProxy = (TiViewProxy) newValue;
            initRight();
            this.rightFrame.addView(newProxy.getOrCreateView().getOuterView(), index);
        } else {
            Log.e(TAG, "invalid type for rightView");
        }
        if (this.rightView != null) {
            this.rightFrame.removeView(this.rightView.getOrCreateView().getNativeView());
        }
        this.rightView = newProxy;

    } else if (key.equals(TiC.PROPERTY_CENTER_VIEW)) {
        TiViewProxy newProxy = (TiViewProxy) newValue;
        setCenterView(newProxy);

    } else if (key.equals(TiC.PROPERTY_LEFT_WIDTH)) {
        if (leftFrame == null) {
            return;
        }
        initLeft();

        if (newValue.equals(TiC.LAYOUT_SIZE)) {
            leftWidth = LayoutParams.WRAP_CONTENT;
        } else if (newValue.equals(TiC.LAYOUT_FILL)) {
            leftWidth = LayoutParams.MATCH_PARENT;
        } else if (!newValue.equals(TiC.SIZE_AUTO)) {
            leftWidth = getDevicePixels(newValue);
        }

        LayoutParams leftFrameLayout = new LayoutParams(leftWidth, LayoutParams.MATCH_PARENT);
        leftFrameLayout.gravity = Gravity.START;
        this.leftFrame.setLayoutParams(leftFrameLayout);

    } else if (key.equals(TiC.PROPERTY_RIGHT_WIDTH)) {
        if (rightFrame == null) {
            return;
        }
        initRight();

        if (newValue.equals(TiC.LAYOUT_SIZE)) {
            rightWidth = LayoutParams.WRAP_CONTENT;
        } else if (newValue.equals(TiC.LAYOUT_FILL)) {
            rightWidth = LayoutParams.MATCH_PARENT;
        } else if (!newValue.equals(TiC.SIZE_AUTO)) {
            rightWidth = getDevicePixels(newValue);
        }

        LayoutParams rightFrameLayout = new LayoutParams(rightWidth, LayoutParams.MATCH_PARENT);
        rightFrameLayout.gravity = Gravity.END;
        this.rightFrame.setLayoutParams(rightFrameLayout);

    } else if (key.equals(TiC.PROPERTY_DRAWER_LOCK_MODE)) {
        layout.setDrawerLockMode(TiConvert.toInt(newValue));

    } else if (key.equals(TiC.PROPERTY_DRAWER_INDICATOR_ENABLED)) {
        if (drawerToggle != null) {
            drawerToggle.setDrawerIndicatorEnabled((Boolean) newValue);
        }

    } else if (key.equals(TiC.PROPERTY_TOOLBAR_ENABLED)) {
        toolbarEnabled = TiConvert.toBoolean(newValue);
        setToolbarVisible(toolbarEnabled);

    } else if (key.equals(TiC.PROPERTY_DRAG_MARGIN)) {
        setDrawMargin(getDevicePixels(newValue));
    } else {
        super.propertyChanged(key, oldValue, newValue, proxy);
    }
}

From source file:com.google.blockly.android.AbstractBlocklyActivity.java

/**
 * Configures the activity to support a navigation menu and drawer provided by
 * {@link #onCreateAppNavigationDrawer}.
 *///  www  . ja  v a2 s. c  o  m
protected void setupAppNaviagtionDrawer() {
    DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(
            getResources().getDimensionPixelSize(R.dimen.navigation_drawer_width),
            ViewGroup.LayoutParams.MATCH_PARENT, Gravity.START);
    // Add navigation drawer above the content view, as the first drawer.
    mDrawerLayout.addView(mNavigationDrawer, 1, lp);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close /* "close drawer" description for accessibility */
    ) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);

            supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager
                        .getDefaultSharedPreferences(AbstractBlocklyActivity.this);
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

            supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }
    };

    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });
    mDrawerLayout.addDrawerListener(mDrawerToggle);
}

From source file:com.google.samples.apps.sergio.ui.BaseActivity.java

protected void closeNavDrawer() {
    if (mDrawerLayout != null) {
        mDrawerLayout.closeDrawer(Gravity.START);
    }
}