List of usage examples for android.support.v4.view GravityCompat START
int START
To view the source code for android.support.v4.view GravityCompat START.
Click Source Link
From source file:by.zatta.pilight.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG, "onCreate starts"); setContentView(R.layout.mainactivity_layout); mCurrentTitle = getString(R.string.app_name); SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String language = getPrefs.getString("languagePref", "unknown"); if (!language.equals("unknown")) makeLocale(language);//from w w w . java2s . co m mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerToggle = new CustomActionBarDrawerToggle(this, mDrawer); mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); if (savedInstanceState != null) { Log.v(TAG, "savedInstanceState was not null"); mDevices = savedInstanceState.getParcelableArrayList("config"); mCurrentTitle = savedInstanceState.getString("currentTitle", "oops"); getActionBar().setTitle(mCurrentTitle); initMenu(); } else { mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); openDialogFragment(StatusDialog.newInstance("CONNECTING")); } automaticBind(); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); Log.v(TAG, "onCreate done"); }
From source file:com.esri.android.mapsapp.MapsAppActivity.java
/** * Initializes the navigation drawer./*from www . ja va 2 s .c o m*/ */ private void setupDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.maps_app_activity_drawer_layout); // Set the list's click listener mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // set a custom shadow that overlays the main content when the drawer // opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); updateDrawer(); }
From source file:com.example.messaging.GroupTextActivity.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_home) { Intent intent = new Intent(this, HomePage.class); startActivity(intent);// w w w .ja va2 s. c o m finish(); } else if (id == R.id.nav_teammates) { Intent intent = new Intent(this, SelectGM_Activity.class); startActivity(intent); finish(); } else if (id == R.id.nav_messages) { } else if (id == R.id.nav_leave_sport) { Intent intent = new Intent(this, SelectSport.class); startActivity(intent); finish(); } else if (id == R.id.nav_settings) { Intent intent = new Intent(this, DefaultSettingsActivity.class); startActivity(intent); finish(); } else if (id == R.id.nav_logout) { Intent intent = new Intent(this, FacebookLoginActivity.class); startActivity(intent); finish(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.gm_drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.example.apple.assistapp.MainActivity.java
private void InitialToolBar() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w ww . ja va 2 s . c o m View tView = getLayoutInflater().inflate(R.layout.toolbar, null); img_left = (ImageView) tView.findViewById(R.id.img_left); img_right = (ImageView) tView.findViewById(R.id.img_right); img_left.setOnClickListener(new OnClickListener() { public void onClick(View v) { mDrawerLayout.openDrawer(GravityCompat.START); } }); img_right.setOnClickListener(new OnClickListener() { public void onClick(View v) { mDrawerLayout.openDrawer(GravityCompat.END); } }); toolbar.addView(tView); }
From source file:am.project.x.business.main.MainActivity.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.main_nav_widgets: setTitle(item.getTitle());//ww w . java 2 s. c o m setFragment(TAG_WIDGETS); break; case R.id.main_nav_drawables: setTitle(item.getTitle()); setFragment(TAG_DRAWABLES); break; case R.id.main_nav_others: setTitle(item.getTitle()); setFragment(TAG_OTHERS); break; case R.id.main_nav_develop: setTitle(item.getTitle()); setFragment(TAG_DEVELOP); break; case R.id.main_nav_report: ContextUtils.openBrowser(this, REPORT); break; case R.id.main_nav_contact: ContextUtils.sendEmail(this, null, null, EMAIL); break; case R.id.main_nav_about: AboutActivity.start(this); break; } mVDrawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.afg.MngProductContentProvider.Home_Activity.java
public void setupDrawerContent() { mNav.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override// w w w . ja va 2s . c o m public boolean onNavigationItemSelected(@NonNull MenuItem item) { item.setChecked(true); switch (item.getItemId()) { case R.id.action_home: showHome(); break; case R.id.action_list: showList(); break; case R.id.pharmacy: showPharmacy(); break; case R.id.action_sales: showSales(); break; case R.id.category: showListCategories(); default: item.setChecked(false); break; } mDrawer.closeDrawer(GravityCompat.START); setTitle(item.getTitle()); return true; } }); }
From source file:at.tugraz.ist.akm.activities.MainActivity.java
@Override public void onBackPressed() { if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { mDrawerLayout.closeDrawer(GravityCompat.START); } else if (null == getFragmentManager().findFragmentByTag(mDrawerFragments[0])) { fragmentTransaction(mDrawerFragments[0]); } else {//from w w w .ja v a2 s. co m finish(); } }
From source file:android.support.design.widget.CollapsingToolbarLayout.java
public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); mCollapsingTextHelper = new CollapsingTextHelper(this); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr, R.style.Widget_Design_CollapsingToolbar); mCollapsingTextHelper.setExpandedTextGravity(a.getInt( R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM)); mCollapsingTextHelper// w ww . ja v a2 s .com .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity, GravityCompat.START | Gravity.CENTER_VERTICAL)); mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0); if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) { mExpandedMarginStart = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) { mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) { mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) { mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0); } mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true); setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title)); // First load the default text appearances mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded); mCollapsingTextHelper.setCollapsedTextAppearance( android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Title); // Now overlay any custom text appearances if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) { mCollapsingTextHelper.setExpandedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0)); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) { mCollapsingTextHelper.setCollapsedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0)); } mScrimVisibleHeightTrigger = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_scrimVisibleHeightTrigger, -1); mScrimAnimationDuration = a.getInt(R.styleable.CollapsingToolbarLayout_scrimAnimationDuration, DEFAULT_SCRIM_ANIMATION_DURATION); setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim)); setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim)); mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1); a.recycle(); setWillNotDraw(false); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return onWindowInsetChanged(insets); } }); }
From source file:com.armtimes.drawer.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * * @param fragmentId The android:id of this fragment in its activity's layout. * @param drawerLayout The DrawerLayout containing this fragment's UI. */// ww w .j a v a 2s. co m public void setUp(int fragmentId, DrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ 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); if (!isAdded()) { return; } getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } 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(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!mUserLearnedDrawer && !mFromSavedInstanceState) { mDrawerLayout.openDrawer(mFragmentContainerView); } // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }
From source file:ca.ualberta.cs.shoven_habittracker.AllHabitsActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*w w w.ja va 2 s . c o m*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_today) { this.finish(); } else if (id == R.id.nav_all_habits) { } else if (id == R.id.nav_delete) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.check_if_clear); builder.setPositiveButton(R.string.clear_all_data, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(AllHabitsActivity.this, "All data cleared", Toast.LENGTH_SHORT).show(); clearData(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); AlertDialog dialog = builder.create(); dialog.show(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }