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:com.bradbergeron.splitviewcontrollerdemo.activities.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    final boolean drawerOpen = mDrawerLayout.isDrawerOpen(Gravity.START);
    menu.findItem(R.id.mainMenu_aboutMenuItem).setVisible(!drawerOpen);

    return super.onPrepareOptionsMenu(menu);
}

From source file:com.twitt4droid.app.activity.MainActivity.java

private void setUpDrawer() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open,
            R.string.drawer_close) {/*from   w  ww  .ja va 2  s. c  om*/

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getSupportActionBar().setTitle(R.string.app_name);
            supportInvalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            getSupportActionBar().setTitle(currentTitleId);
            supportInvalidateOptionsMenu();
        }
    };

    drawerLayout.setDrawerListener(drawerToggle);
    drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
    drawerLayout.setStatusBarBackground(R.color.primary_dark_color);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    setUpDrawerMenu();
}

From source file:com.acious.android.paginationseekbar.internal.PopupIndicator.java

private WindowManager.LayoutParams createPopupLayout(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.gravity = Gravity.START | Gravity.TOP;
    p.width = ViewGroup.LayoutParams.MATCH_PARENT;
    p.height = ViewGroup.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;/*from   w w w  .ja va  2 s  .  co m*/
    p.flags = computeFlags(p.flags);
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
    p.setTitle("PaginationSeekBar Indicator:" + Integer.toHexString(hashCode()));

    return p;
}

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

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

    instanceState = savedInstanceState;//from ww w . ja v a 2s. c o  m

    if (!getSharedPreferences(Constants.PREFS_TAG, Context.MODE_PRIVATE).getBoolean("hasTutorialShown", false))
        startActivity(new Intent(this, TutorialActivity.class));

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;
    } else
        isLandscapeLarge = false;

    mDrawerList = (ExpandableListView) findViewById(R.id.left_drawer_list);

    mFooter = LayoutInflater.from(this).inflate(R.layout.drawer_list_footer, mDrawerList, false);
    mDrawerList.addFooterView(mFooter);
    mShadow = findViewById(R.id.drop_shadow);

    if (!isLandscapeLarge) {
        mDrawerList.addHeaderView(
                LayoutInflater.from(this).inflate(R.layout.drawer_list_header, mDrawerList, false), null,
                false);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
        mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            SysUtils.setTopStatusMargin(this, mDrawerLayout);
    }

    mDrawerList.setGroupIndicator(null);
    mDrawerList.setOnGroupClickListener(this);
    mDrawerList.setOnChildClickListener(this);
    mDrawerList.setOnGroupExpandListener(this);

    mMenuAdapter = new MenuAdapter(this);
    mDrawerList.setAdapter(mMenuAdapter);

    if (!isLandscapeLarge) {
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, getToolbar(), R.string.drawer_open,
                R.string.drawer_close);
        mDrawerLayout.setDrawerListener(mDrawerToggle);
    }

    mFooter.findViewById(R.id.unlock_premium_btn).setVisibility(View.GONE);
    try {
        mHelper = new IabHelper(this, Constants.LICENSE_KEY);
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                isLicensed = result.isSuccess();
                if (isLicensed)
                    mHelper.queryInventoryAsync(MainActivity.this);
                else
                    SysUtils.toggleAppWidgets(MainActivity.this, false);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (savedInstanceState != null) {
        prevSelection = savedInstanceState.getByte("prevSelection");

        mMenuAdapter.toggleSelection(0);
        if (prevSelection != 2)
            mMenuAdapter.toggleSelection(prevSelection);

        selectMenuItem(prevSelection);
    } else
        selectMenuItem(0);
}

From source file:com.jungle.apps.photos.module.homepage.HomepageActivity.java

private void switchDrawer() {
    if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
        closeDrawer();
    } else {
        openDrawer();
    }
}

From source file:cn.njmeter.njmeter.widget.spinner.NiceSpinner.java

private void init(Context context, AttributeSet attrs) {
    Resources resources = getResources();
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NiceSpinner);
    int defaultPadding = resources.getDimensionPixelSize(R.dimen.one_and_a_half_grid_unit);

    setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
    setPadding(resources.getDimensionPixelSize(R.dimen.three_grid_unit), defaultPadding, defaultPadding,
            defaultPadding);//w  ww .ja v a 2 s  . com
    setClickable(true);

    backgroundSelector = typedArray.getResourceId(R.styleable.NiceSpinner_backgroundSelector,
            R.drawable.selector);
    setBackgroundResource(backgroundSelector);
    textColor = typedArray.getColor(R.styleable.NiceSpinner_textTint, getDefaultTextColor(context));
    setTextColor(textColor);

    listView = new ListView(context);
    // Set the spinner's id into the listview to make it pretend to be the right parent in
    // onItemClick
    listView.setId(getId());
    listView.setDivider(new ColorDrawable(Color.GRAY));
    listView.setDividerHeight(1);
    listView.setItemsCanFocus(true);
    //hide vertical and horizontal scrollbars
    listView.setVerticalScrollBarEnabled(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setOverScrollMode(OVER_SCROLL_NEVER);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectedIndex = position;

            if (onItemClickListener != null) {
                onItemClickListener.onItemClick(parent, view, position, id);
            }

            if (onItemSelectedListener != null) {
                onItemSelectedListener.onItemSelected(parent, view, position, id);
            }

            adapter.setSelectedIndex(position);
            setTextInternal(adapter.getItemInDataset(position).toString());
            dismissDropDown();
        }
    });

    popupWindow = new PopupWindow(context);
    popupWindow.setContentView(listView);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        popupWindow.setElevation(DEFAULT_ELEVATION);
        popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.spinner_drawable));
    } else {
        popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.drop_down_shadow));
    }

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            if (!isArrowHidden) {
                animateArrow(false);
            }
        }
    });

    isArrowHidden = typedArray.getBoolean(R.styleable.NiceSpinner_hideArrow, false);
    arrowDrawableTint = typedArray.getColor(R.styleable.NiceSpinner_arrowTint, Integer.MAX_VALUE);
    arrowDrawableResId = typedArray.getResourceId(R.styleable.NiceSpinner_arrowDrawable, R.drawable.arrow);
    dropDownListPaddingBottom = typedArray
            .getDimensionPixelSize(R.styleable.NiceSpinner_dropDownListPaddingBottom, 0);
    typedArray.recycle();

    measureDisplayHeight();
}

From source file:org.weyoung.xianbicycle.BaseActivity.java

private void setupNavDrawer() {
    // What nav drawer item should be selected?
    int selfItem = getCurrentNavDrawerItem();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;//  ww w.  jav  a 2 s.c o  m
    }
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    ScrollView navDrawer = (ScrollView) 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 (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;
            }
            onNavDrawerStateChanged(false, false);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            if (showcaseView != null && showcaseView.isShowing()) {
                showcaseView.hide();
            }
            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();

    goToNavDrawerItem(NAVDRAWER_ITEM_DEFAULT);
}

From source file:org.akop.crosswords.activity.MainActivity.java

@Override
public void onFolderSelected(long id, String title) {
    setTitle(title);//w  w w .  j  a  v a 2 s . c  om

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentByTag(FRAGMENT_TAG_PUZZLES);

    if (fragment instanceof FoldersFragment.OnFolderSelectedListener) {
        FoldersFragment.OnFolderSelectedListener listener = (FoldersFragment.OnFolderSelectedListener) fragment;
        listener.onFolderSelected(id, title);
    }

    if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
        mDrawerLayout.closeDrawer(Gravity.START);
    }
}

From source file:com.jungle.apps.photos.module.homepage.HomepageActivity.java

private void openDrawer() {
    mDrawerLayout.openDrawer(Gravity.START);
    mNavigateView.setImageResource(R.drawable.expand);
}

From source file:in.sc9.discreteslider.internal.PopupIndicator.java

private WindowManager.LayoutParams createPopupLayout(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.gravity = Gravity.START | Gravity.TOP;
    p.width = ViewGroup.LayoutParams.MATCH_PARENT;
    p.height = ViewGroup.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;/*from  w ww . j  a v  a  2  s  .c om*/
    p.flags = computeFlags(p.flags);
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
    p.setTitle("DiscreteSlider Indicator:" + Integer.toHexString(hashCode()));

    return p;
}