Change font of the floating label EditText and TextInputLayout

As of Design Library v23, you can use TextInputLayout#setTypeface(). This will set the typeface on both the expanded and floating hint. Here is the feature request where it was discussed on b.android.com. EDIT: The error view typeface was not being set, but is now fixed in v25.1.0.

What are the new features of Android Design Support Library and how to use its Snackbar?

The new Snackbar doesn’t require Android-M. It is inside the new design support library and you can use it today. Just update your SDK add this dependency in your code: compile ‘com.android.support:design:22.2.0’ You can use a code like this: Snackbar.make(view, “Here’s a Snackbar”, Snackbar.LENGTH_LONG) .setAction(“Action”, null) .show(); It is like a Toast. To assign an … Read more

NestedScrollView and CoordinatorLayout. Issue on Scrolling

This can also be observed in the cheesesquare demo when removing all but one card in the details fragment. I was able to solve this (for now) using this class: https://gist.github.com/EmmanuelVinas/c598292f43713c75d18e <android.support.v4.widget.NestedScrollView android:layout_width=”match_parent” android:layout_height=”match_parent” app:layout_behavior=”com.evs.demo.layout.FixedScrollingViewBehavior”> ….. </android.support.v4.widget.NestedScrollView>

Error text in TextInputLayout is covered by keyboard

Update: looks like this might have been fixed in 1.2.0-alpha03 version of the library. To make sure the error message is visible without the user acting to see it, I subclassed TextInputLayout and placed it inside a ScrollView. This lets me scroll down if needed to reveal the error message, on every occasion the error … Read more

Smooth animated Collapsing Toolbar with Android Design Support Library

You can use the new layout_scrollFlag snap for smooth scroll within the AppBarLayout states. But what I have experienced is that, when the RecyclerView reaches top, scrolling stops. i.e CollapsingToolbarLayout won’t get expanded without another scroll. For the RecyclerView to scroll smoothly up and expand the CollapsingToolbarLayout I have used a ScrollListener on recyclerview. recyclerView.addOnScrollListener(new … Read more

onClick method not working properly after NestedScrollView scrolled

I found solution for same problem on this thread :The item inside RecyclerView can’t be clicked right after scrolling You can fix your code by adding layout_behavior to your AppBarLayout.You can find code here Fixed AppBarLayout.Behavior .Just add this class tou your project and fix your code : <android.support.design.widget.AppBarLayout android:layout_width=”match_parent” app:layout_behavior=”yourPackageName.FixAppBarLayoutBehavior” android:layout_height=”wrap_content”>

Android TabLayout Android Design

I’ve just managed to setup new TabLayout, so here are the quick steps to do this (ノ◕ヮ◕)ノ*:・゚✧ Add dependencies inside your build.gradle file: dependencies { compile ‘com.android.support:design:23.1.1’ } Add TabLayout inside your layout <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”?attr/colorPrimary”/> <android.support.design.widget.TabLayout android:id=”@+id/tab_layout” android:layout_width=”match_parent” android:layout_height=”wrap_content”/> <android.support.v4.view.ViewPager android:id=”@+id/pager” android:layout_width=”match_parent” android:layout_height=”match_parent”/> </LinearLayout> … Read more

how to remove left margin of Android Toolbar?

replace your xml with below xml <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:layout_alignParentTop=”true” android:background=”?attr/colorPrimary” android:elevation=”@dimen/margin_padding_8dp” android:contentInsetStart=”0dp” android:contentInsetLeft=”0dp” android:contentInsetRight=”0dp” android:contentInsetEnd=”0dp” app:contentInsetLeft=”0dp” app:contentInsetStart=”0dp” app:contentInsetRight=”0dp” app:contentInsetEnd=”0dp”> <RelativeLayout android:id=”@+id/rlToolbar” android:layout_width=”match_parent” android:layout_height=”match_parent”> <TextView android:id=”@+id/tvTitle” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerInParent=”true” android:paddingRight=”@dimen/margin_padding_16dp” android:text=”AppBar” android:textAppearance=”@style/TextAppearance.AppCompat” android:textColor=”@color/white” android:textSize=”@dimen/text_size_20sp” /> </RelativeLayout>

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” … Read more

Dynamically add and remove tabs in TabLayout(material design) android

Remove tab from TabLayout … public void removeTab(int position) { if (mTabLayout.getTabCount() >= 1 && position<mTabLayout.getTabCount()) { mTabLayout.removeTabAt(position); mPagerAdapter.removeTabPage(position); } } … Add a removeTabPage method to your PagerAdapter … public void removeTabPage(int position) { if (!tabItems.isEmpty() && position<tabItems.size()) { tabItems.remove(position); notifyDataSetChanged(); } } … Add a Tab … private void addTab(String title) { mTabLayout.addTab(mTabLayout.newTab().setText(title)); … Read more