Snackbar action text color not changing

The argument of setActionTextColor is the int that represents the color, not the resource ID. Instead of this: .setActionTextColor(R.color.yellow) try: .setActionTextColor(Color.YELLOW) If you want to use resources anyway, try: .setActionTextColor(ContextCompat.getColor(context, R.color.color_name)); Note: To use ContextCompat, I assume you have included Support library to your build.gradle file (It is optional if you have already appcompat (v7) … Read more

TabLayout set spacing or margin each tab

Been fighting this problem for a while too, found the solution on this thread : Android Design Support Library TabLayout using custom tabs layout but layout wrapping the tabs <!– Add the padding to tabPaddingStart and/or tabPaddingEnd –> <android.support.design.widget.TabLayout android:id=”@+id/tabLayout” android:layout_width=”match_parent” android:layout_height=”@dimen/tab_layout_height” app:tabPaddingStart=”10dp” app:tabPaddingEnd=”10dp”>

CoordinatorLayout with RecyclerView And Collapsing header

You can achieve it by having 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.support.design.widget.AppBarLayout android:layout_width=”match_parent” android:layout_height=”wrap_content”> <android.support.design.widget.CollapsingToolbarLayout android:layout_width=”match_parent” android:layout_height=”match_parent” app:layout_scrollFlags=”scroll|exitUntilCollapsed”> <!– HEADER –> <RelativeLayout … app:layout_collapseMode=”parallax”> ….. </RelativeLayout> <android.support.v7.widget.Toolbar android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” app:layout_collapseMode=”pin” /> </android.support.design.widget.CollapsingToolbarLayout> <!– IF YOU WANT TO KEEP “Choose Item” always on top of the RecyclerView, put this TextView here <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” … Read more

Floating Action Button not showing fully inside a fragment

It’s not an acceptable solution to have to show/hide the FAB whatever tab is selected. I’ve tried every layout combination, but moving the FAB to the activity layout was the only solution that worked. But what if you need the button only in one tab? It’s the only way that works now, but I’m expecting … Read more

Can’t use srcCompat for ImageViews in android

Don’t android:srcCompat=”https://stackoverflow.com/questions/35645148/@drawable/wallpaper” Do app:srcCompat=”https://stackoverflow.com/questions/35645148/@drawable/wallpaper” as it srcCompat attribute is actually defined within AppCompat library. Important you will need to add appropriate namespace for this. xmlns:app=”http://schemas.android.com/apk/res-auto” Important what you are getting it seems like it is just a lint error that can be ignored. I have tried and have the same error, but it is working … Read more

Add app bar scrolling view behavior to multiple views in CoordinatorLayout

You don’t need a workaround or something strange. This behaviour is supported by the library. Just replace your LinearLayout by this and put it below the RecyclerView: <android.support.v4.widget.NestedScrollView android:layout_width=”match_parent” android:layout_height=”wrap_content” app:layout_behavior=”@string/appbar_scrolling_view_behavior”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” android:gravity=”center”> <Button android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:padding=”15dp” android:text=”Button text”/> </LinearLayout> </android.support.v4.widget.NestedScrollView> Also you will need to put this in your RecyclerView to … Read more

How to reset the Toolbar position controlled by the CoordinatorLayout?

To reset the scroll state, just get the AppBarLayout.Behavior object CoordinatorLayout coordinator = (CoordinatorLayout) findViewById(R.id.coordinator); AppBarLayout appbar = (AppBarLayout) findViewById(R.id.appbar); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appbar.getLayoutParams(); AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior(); and call onNestedPreScroll method manually: int[] consumed = new int[2]; behavior.onNestedPreScroll(coordinator, appbar, null, 0, -1000, consumed); If you would like to reset smoothly with an … Read more