android-toolbar
Change title color in toolbar?
Programatically: toolbar.setTitleTextColor(0xFFFFFFFF);
How to use a TabLayout with Toolbar inside CollapsingToolbarLayout?
Here’s the way I managed to do this, I don’t think that’s the best solution though if anyone finds a better way please feel free to post the answer. <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/main_content” android:layout_width=”match_parent” android:layout_height=”match_parent” android:fitsSystemWindows=”true”> <android.support.v4.view.ViewPager android:id=”@+id/viewpager” android:layout_width=”match_parent” android:layout_height=”match_parent” app:layout_behavior=”@string/appbar_scrolling_view_behavior” /> <android.support.design.widget.AppBarLayout android:id=”@+id/appbar” android:layout_width=”match_parent” android:layout_height=”@dimen/detail_backdrop_height” android:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar” android:fitsSystemWindows=”true”> <android.support.design.widget.CollapsingToolbarLayout android:id=”@+id/collapsing_toolbar” android:layout_width=”match_parent” android:layout_height=”206dip” android:background=”@color/primary_dark” app:layout_scrollFlags=”scroll|exitUntilCollapsed” android:fitsSystemWindows=”true” …
Add elevation/shadow on toolbar for pre-lollipop devices
For Android 5.0 and above : AppBarLayout automatically provides/gives shadow in the layout. You can also increase the elevation of the AppBarLayout by app:elevation=”4dp”. For Pre-Lollipop : You can use the following link: https://github.com/vipulasri/Toolbar-Elevation-Pre-Lollipop Note: Toolbar also supports elevation to it, using android:elevation=”4dp” New Update: In Appcompat v24.0.0, you can not set elevation to AppBarLayout …
How to center toolbar back button?
From the developer.android.com : Toolbar supports a more focused feature set than ActionBar. From start to end, a toolbar may contain a combination of the following optional elements: A navigation button. This may be an Up arrow, navigation menu toggle, close, collapse, done or another glyph of the app’s choosing. This button should always be …
How to display menu item with icon and text in AppCompatActivity
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. // getMenuInflater().inflate(R.menu.menu_patient_home_screen, menu); menu.add(0, 1, 1, menuIconWithText(getResources().getDrawable(R.mipmap.user_2), getResources().getString(R.string.action_profile))); menu.add(0, 2, 2, menuIconWithText(getResources().getDrawable(R.mipmap.add_user), getResources().getString(R.string.action_add_user))); menu.add(0, 3, 3, menuIconWithText(getResources().getDrawable(R.mipmap.switch_profile), getResources().getString(R.string.action_switch_profile))); menu.add(0, 4, 4, menuIconWithText(getResources().getDrawable(R.mipmap.logout), getResources().getString(R.string.action_sign_out))); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle …
AppBarLayout with FrameLayout container as scrolling content doesn’t work
Replace your FrameLayout with android.support.v4.widget.NestedScrollView NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default. Link to doc
Android Lollipop, add popup menu from title in toolbar
You’re going to need to add a Spinner to the Toolbar: <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_height=”?attr/actionBarSize” android:layout_width=”match_parent” android:background=”?attr/colorPrimary”> <Spinner android:id=”@+id/spinner_nav” android:layout_width=”wrap_content” android:layout_height=”wrap_content” /> </android.support.v7.widget.Toolbar> You will then need to disable the default title: Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); You can then retrieve and setup the Spinner as needed in your Activity/Fragment.