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:org.catrobat.paintroid.MainActivity.java

@Override
public void onBackPressed() {
    if (!mToolbarIsVisible) {
        setFullScreen(false);/*from www . j  a v  a 2  s  . co  m*/
    } 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:android.support.v7.widget.ToolbarWidgetWrapper.java

private void ensureSpinner() {
    if (mSpinner == null) {
        mSpinner = new AppCompatSpinner(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);//from ww  w. j a  v  a  2  s .c  o  m
    }
}

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  a  va  2  s.co  m
                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
    }
}

From source file:com.onenews.widgets.sliding.MultiShrinkScroller.java

/**
 * This method must be called inside the Activity's onCreate. Initialize everything.
 */// w  ww  .  j av  a 2  s.  co m
public void initialize(MultiShrinkScrollerListener listener, boolean isOpenContactSquare) {
    scrollView = (ScrollView) findViewById(R.id.content_scroller);
    scrollViewChild = findViewById(R.id.content_container);
    toolbar = findViewById(R.id.toolbar_parent);
    photoViewContainer = findViewById(R.id.toolbar_parent);
    transparentView = findViewById(R.id.transparent_view);
    largeTextView = (TextView) findViewById(R.id.large_title);
    invisiblePlaceholderTextView = (TextView) findViewById(R.id.placeholder_textview);
    startColumn = findViewById(R.id.empty_start_column);

    // Touching the empty space should close the card
    if (startColumn != null) {
        startColumn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                scrollOffBottom();
            }
        });
        findViewById(R.id.empty_end_column).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                scrollOffBottom();
            }
        });
    }
    this.listener = listener;
    this.isOpenImageSquare = isOpenContactSquare;

    photoView = (ImageView) findViewById(R.id.photo);
    fab = (FloatingActionButton) findViewById(R.id.fab);

    titleGradientView = findViewById(R.id.title_gradient);
    titleGradientView.setBackgroundDrawable(titleGradientDrawable);
    actionBarGradientView = findViewById(R.id.action_bar_gradient);
    actionBarGradientView.setBackgroundDrawable(actionBarGradientDrawable);
    collapsedTitleStartMargin = ((Toolbar) findViewById(R.id.toolbar)).getContentInsetStart();

    photoTouchInterceptOverlay = findViewById(R.id.photo_touch_intercept_overlay);
    if (!isTwoPanel) {
        photoTouchInterceptOverlay.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                expandHeader();
            }
        });
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            scrollView.setOnScrollChangeListener(new OnScrollChangeListener() {
                @Override
                public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                    updateFabStatus(scrollY);
                }
            });
        } else {
            scrollView.getViewTreeObserver()
                    .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
                        @Override
                        public void onScrollChanged() {
                            updateFabStatus(scrollView.getScrollY());
                        }
                    });
        }
    }

    SchedulingUtils.doOnPreDraw(this, false, new Runnable() {
        @Override
        public void run() {
            if (!isTwoPanel) {
                maximumHeaderHeight = getResources().getDimensionPixelSize(R.dimen.sliding_header_max_height);
                intermediateHeaderHeight = (int) (maximumHeaderHeight * INTERMEDIATE_HEADER_HEIGHT_RATIO);
            }
            setHeaderHeight(getMaximumScrollableHeaderHeight());
            maximumHeaderTextSize = largeTextView.getHeight();
            if (isTwoPanel) {
                maximumHeaderHeight = getHeight();
                minimumHeaderHeight = maximumHeaderHeight;
                intermediateHeaderHeight = maximumHeaderHeight;

                // Permanently set photo width and height.
                final ViewGroup.LayoutParams photoLayoutParams = photoViewContainer.getLayoutParams();
                photoLayoutParams.height = maximumHeaderHeight;
                photoLayoutParams.width = (int) (maximumHeaderHeight * landscapePhotoRatio);
                photoViewContainer.setLayoutParams(photoLayoutParams);

                // Permanently set title width and margin.
                final LayoutParams largeTextLayoutParams = (LayoutParams) largeTextView.getLayoutParams();
                largeTextLayoutParams.width = photoLayoutParams.width - largeTextLayoutParams.leftMargin
                        - largeTextLayoutParams.rightMargin;
                largeTextLayoutParams.gravity = Gravity.BOTTOM | Gravity.START;
                largeTextView.setLayoutParams(largeTextLayoutParams);
            } else {
                // Set the width of largeTextView as if it was nested inside
                // photoViewContainer.
                largeTextView.setWidth(photoViewContainer.getWidth() - 2 * maximumTitleMargin);
            }

            calculateCollapsedLargeTitlePadding();
            updateHeaderTextSizeAndMargin();
            configureGradientViewHeights();
        }
    });
}

From source file:com.microhealthllc.Slide.MultiShrinkScroller.java

/**
 * This method must be called inside the Activity's onCreate. Initialize everything.
 *///  w  ww  .j  av a  2 s  .c om
public void initialize(MultiShrinkScrollerListener listener, boolean isOpenContactSquare) {
    scrollView = (ScrollView) findViewById(R.id.content_scroller);
    scrollViewChild = findViewById(R.id.content_container);
    toolbar = findViewById(R.id.toolbar_parent);
    photoViewContainer = findViewById(R.id.toolbar_parent);
    transparentView = findViewById(R.id.transparent_view);
    largeTextView = (TextView) findViewById(R.id.large_title);
    invisiblePlaceholderTextView = (TextView) findViewById(R.id.placeholder_textview);
    startColumn = findViewById(R.id.empty_start_column);

    // Touching the empty space should close the card
    if (startColumn != null) {
        startColumn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                scrollOffBottom();
            }
        });
        findViewById(R.id.empty_end_column).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                scrollOffBottom();
            }
        });
    }
    this.listener = listener;
    this.isOpenImageSquare = isOpenContactSquare;

    photoView = (ImageView) findViewById(R.id.photo);
    fab = (FloatingActionButton) findViewById(R.id.fab);

    titleGradientView = findViewById(R.id.title_gradient);
    titleGradientView.setBackgroundDrawable(titleGradientDrawable);
    actionBarGradientView = findViewById(R.id.action_bar_gradient);
    actionBarGradientView.setBackgroundDrawable(actionBarGradientDrawable);
    collapsedTitleStartMargin = ((Toolbar) findViewById(R.id.toolbar)).getContentInsetStart();

    photoTouchInterceptOverlay = findViewById(R.id.photo_touch_intercept_overlay);
    if (!isTwoPanel) {
        photoTouchInterceptOverlay.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                expandHeader();
            }
        });
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            scrollView.setOnScrollChangeListener(new OnScrollChangeListener() {
                @Override
                public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                    updateFabStatus(scrollY);
                }
            });
        } else {
            scrollView.getViewTreeObserver()
                    .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
                        @Override
                        public void onScrollChanged() {
                            updateFabStatus(scrollView.getScrollY());
                        }
                    });
        }
    }

    SchedulingUtils.doOnPreDraw(this, false, new Runnable() {
        @Override
        public void run() {
            if (!isTwoPanel) {
                maximumHeaderHeight = getResources().getDimensionPixelSize(R.dimen.sliding_header_max_height);
                intermediateHeaderHeight = (int) (maximumHeaderHeight * intermediateHeaderHeightRatio);
            }
            setHeaderHeight(getMaximumScrollableHeaderHeight());
            maximumHeaderTextSize = largeTextView.getHeight();
            if (isTwoPanel) {
                maximumHeaderHeight = getHeight();
                minimumHeaderHeight = maximumHeaderHeight;
                intermediateHeaderHeight = maximumHeaderHeight;

                // Permanently set photo width and height.
                final ViewGroup.LayoutParams photoLayoutParams = photoViewContainer.getLayoutParams();
                photoLayoutParams.height = maximumHeaderHeight;
                photoLayoutParams.width = (int) (maximumHeaderHeight * landscapePhotoRatio);
                photoViewContainer.setLayoutParams(photoLayoutParams);

                // Permanently set title width and margin.
                final LayoutParams largeTextLayoutParams = (LayoutParams) largeTextView.getLayoutParams();
                largeTextLayoutParams.width = photoLayoutParams.width - largeTextLayoutParams.leftMargin
                        - largeTextLayoutParams.rightMargin;
                largeTextLayoutParams.gravity = Gravity.BOTTOM | Gravity.START;
                largeTextView.setLayoutParams(largeTextLayoutParams);
            } else {
                // Set the width of largeTextView as if it was nested inside
                // photoViewContainer.
                largeTextView.setWidth(photoViewContainer.getWidth() - 2 * maximumTitleMargin);
            }

            calculateCollapsedLargeTitlePadding();
            updateHeaderTextSizeAndMargin();
            configureGradientViewHeights();
        }
    });
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

private void setupNavDrawerButton() {
    if (mActionBarToolbar != null) {
        mActionBarToolbar.setNavigationIcon(R.drawable.ic_drawer);
        mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override/*w w w  . ja v  a  2  s  .  c  o  m*/
            public void onClick(View view) {
                mDrawerLayout.openDrawer(Gravity.START);
            }
        });
    }
}

From source file:com.google.samples.apps.sergio.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.
 *///from   w w w.  j a va2s .c  o m
private void setupNavDrawer() {
    // What nav drawer item should be selected?
    int selfItem = getSelfNavDrawerItem();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.theme_primary_dark));
    ScrimInsetsScrollView navDrawer = (ScrimInsetsScrollView) mDrawerLayout.findViewById(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(R.id.chosen_account_content_view);
        final View chosenAccountView = findViewById(R.id.chosen_account_view);
        final int navDrawerChosenAccountHeight = getResources()
                .getDimensionPixelSize(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(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(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:com.klinker.android.sliding.MultiShrinkScroller.java

/**
 * This method must be called inside the Activity's onCreate. Initialize everything.
 *///from www.  j  a va2 s.c om
public void initialize(MultiShrinkScrollerListener listener, boolean isOpenContactSquare) {
    scrollView = (NestedScrollView) findViewById(R.id.content_scroller);
    scrollViewChild = findViewById(R.id.content_container);
    toolbar = findViewById(R.id.toolbar_parent);
    photoViewContainer = findViewById(R.id.toolbar_parent);
    transparentView = findViewById(R.id.transparent_view);
    largeTextView = (TextView) findViewById(R.id.large_title);
    invisiblePlaceholderTextView = (TextView) findViewById(R.id.placeholder_textview);
    startColumn = findViewById(R.id.empty_start_column);

    // Touching the empty space should close the card
    if (startColumn != null) {
        startColumn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                scrollOffBottom();
            }
        });
        findViewById(R.id.empty_end_column).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                scrollOffBottom();
            }
        });
    }
    this.listener = listener;
    this.isOpenImageSquare = isOpenContactSquare;

    photoView = (ImageView) findViewById(R.id.photo);
    fab = (FloatingActionButton) findViewById(R.id.fab);

    titleGradientView = findViewById(R.id.title_gradient);
    titleGradientView.setBackgroundDrawable(titleGradientDrawable);
    actionBarGradientView = findViewById(R.id.action_bar_gradient);
    actionBarGradientView.setBackgroundDrawable(actionBarGradientDrawable);
    collapsedTitleStartMargin = ((Toolbar) findViewById(R.id.toolbar)).getContentInsetStart();

    photoTouchInterceptOverlay = findViewById(R.id.photo_touch_intercept_overlay);
    if (!isTwoPanel) {
        photoTouchInterceptOverlay.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                expandHeader();
            }
        });
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            scrollView.setOnScrollChangeListener(new OnScrollChangeListener() {
                @Override
                public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                    updateFabStatus(scrollY);
                }
            });
        } else {
            scrollView.getViewTreeObserver()
                    .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
                        @Override
                        public void onScrollChanged() {
                            updateFabStatus(scrollView.getScrollY());
                        }
                    });
        }
    }

    SchedulingUtils.doOnPreDraw(this, false, new Runnable() {
        @Override
        public void run() {
            if (!isTwoPanel) {
                maximumHeaderHeight = getResources().getDimensionPixelSize(R.dimen.sliding_header_max_height);
                intermediateHeaderHeight = (int) (maximumHeaderHeight * intermediateHeaderHeightRatio);
            }
            setHeaderHeight(getMaximumScrollableHeaderHeight());
            maximumHeaderTextSize = largeTextView.getHeight();
            if (isTwoPanel) {
                maximumHeaderHeight = getHeight();
                minimumHeaderHeight = maximumHeaderHeight;
                intermediateHeaderHeight = maximumHeaderHeight;

                // Permanently set photo width and height.
                final ViewGroup.LayoutParams photoLayoutParams = photoViewContainer.getLayoutParams();
                photoLayoutParams.height = maximumHeaderHeight;
                photoLayoutParams.width = (int) (maximumHeaderHeight * landscapePhotoRatio);
                photoViewContainer.setLayoutParams(photoLayoutParams);

                // Permanently set title width and margin.
                final LayoutParams largeTextLayoutParams = (LayoutParams) largeTextView.getLayoutParams();
                largeTextLayoutParams.width = photoLayoutParams.width - largeTextLayoutParams.leftMargin
                        - largeTextLayoutParams.rightMargin;
                largeTextLayoutParams.gravity = Gravity.BOTTOM | Gravity.START;
                largeTextView.setLayoutParams(largeTextLayoutParams);
            } else {
                // Set the width of largeTextView as if it was nested inside
                // photoViewContainer.
                largeTextView.setWidth(photoViewContainer.getWidth() - 2 * maximumTitleMargin);
            }

            calculateCollapsedLargeTitlePadding();
            updateHeaderTextSizeAndMargin();
            configureGradientViewHeights();
        }
    });
}

From source file:com.near.chimerarevo.activities.MainActivity.java

@Override
public void onBackPressed() {
    if (curFragment instanceof WebFragment) {
        if (mDrawerLayout == null || !mDrawerLayout.isDrawerOpen(Gravity.START)) {
            WebFragment web = (WebFragment) curFragment;
            if (web.canGoBack()) {
                web.goBack();/*  w w  w  . j a  v a2 s . c  o m*/
                return;
            }
        }
    }

    if (mDrawerLayout != null) {
        if (mDrawerLayout.isDrawerOpen(Gravity.START))
            mDrawerLayout.closeDrawers();
        else
            super.onBackPressed();
    } else
        super.onBackPressed();
}

From source file:com.alirezaafkar.toolbar.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 v a  2  s. c o  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);
                RtlToolbar.LayoutParams lp = (RtlToolbar.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);
        }
    }
}