CollapsingToolbarLayout subtitle

If you want the subtitle to go to Toolbar when the AppBar is fully collapsed you should create your custom CoordinatorLayout.Behaviour Like this: Github Guide But if you just want a smaller text behind the title when the AppBar is expanded you can try this layout: <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”match_parent” android:fitsSystemWindows=”true”> <android.support.design.widget.AppBarLayout android:id=”@+id/appbar” android:layout_width=”match_parent” … Read more

NavigationView menu items with counter on the right

Starting from version 23 of appcompat-v7 NavigationView supports action views, so it is quite easy to implement counter yourself. Create counter layout, i.e. menu_counter.xml: <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”match_parent” android:gravity=”center_vertical” android:textAppearance=”@style/TextAppearance.AppCompat.Body2″ /> Reference it in your drawer menu xml, i.e. menu/drawer.xml: <item … app:actionLayout=”@layout/menu_counter” /> Note that you should use app namespace, don’t … Read more

Add views below toolbar in CoordinatorLayout

Take the attribute app:layout_behavior=”@string/appbar_scrolling_view_behavior” off the RecyclerView and put it on the FrameLayout that you are trying to show under the Toolbar. I’ve found that one important thing the scrolling view behavior does is to layout the component below the toolbar. Because the FrameLayout has a descendant that will scroll (RecyclerView), the CoordinatorLayout will get … Read more

How to set the divider between Tabs in TabLayout of design support library?

TabLayout is actually HorizontalScrollView and it’s first child is LinearLayout. So just use below code to add dividers View root = tabLayout.getChildAt(0); if (root instanceof LinearLayout) { ((LinearLayout) root).setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); GradientDrawable drawable = new GradientDrawable(); drawable.setColor(getResources().getColor(R.color.separator)); drawable.setSize(2, 1); ((LinearLayout) root).setDividerPadding(10); ((LinearLayout) root).setDividerDrawable(drawable); } Below is the sample screen shot Screen 1 Screen 2

Change the color of a checked menu item in a navigation drawer

Well you can achieve this using Color State Resource. If you notice inside your NavigationView you’re using app:itemIconTint=”@color/black” app:itemTextColor=”@color/primary_text” Here instead of using @color/black or @color/primary_test, use a Color State List Resource. For that, first create a new xml (e.g drawer_item.xml) inside color directory (which should be inside res directory.) If you don’t have a … Read more

Error inflating class android.support.design.widget.NavigationView

Actually it is not the matter of the primarycolortext, upgrading or downgrading the dependencies.This problem will likely occur when the version of your appcompat library and design support library doesn’t match. Example of matching condition compile ‘com.android.support:appcompat-v7:23.1.1’ // appcompat library compile ‘com.android.support:design:23.1.1’ //design support library