Android How to implement Bottom Sheet from Material Design docs

Edit The BottomSheet is now part of the android-support-library. See John Shelleys’ answer. Unfortunately there’s currently no “official” way on how to do this (at least none that I’m aware of). Luckily there’s a library called “BottomSheet” (click) which mimics the look and feel of the BottomSheet and supports Android 2.1 and up. In case … Read more

InflateException with FloatingActionButton from Official Design Library

com.android.support:appcompat-v7:21+ added support for tinting widgets on devices running pre android 5.1 (API Level 21). To make use of it make sure you extend or set the AppCompat Theme and use app:backgroundTint instead of android:backgroundTint. Example: <android.support.design.widget.FloatingActionButton xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/fab” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_margin=”16dp” android:src=”https://stackoverflow.com/questions/30870443/@drawable/icon” app:backgroundTint=”@color/accent” app:borderWidth=”0dp” />

Android changing Floating Action Button color

As described in the documentation, by default it takes the color set in styles.xml attribute colorAccent. The background color of this view defaults to the your theme’s colorAccent. If you wish to change this at runtime then you can do so via setBackgroundTintList(ColorStateList). If you wish to change the color in XML with attribute app:backgroundTint … Read more

FloatingActionButton example with Support Library

So in your build.gradle file, add this: compile ‘com.android.support:design:27.1.1′ AndroidX Note: Google is introducing new AndroidX extension libraries to replace the older Support Libraries. To use AndroidX, first make sure you’ve updated your gradle.properties file, edited build.gradle to set compileSdkVersion to 28 (or higher), and use the following line instead of the previous compile one. … Read more

How can I add the new “Floating Action Button” between two widgets/layouts

Best practice: Add compile ‘com.android.support:design:25.0.1’ to gradle file Use CoordinatorLayout as root view. Add layout_anchorto the FAB and set it to the top view Add layout_anchorGravity to the FAB and set it to: bottom|right|end <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”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <LinearLayout android:id=”@+id/viewA” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”0.6″ android:background=”@android:color/holo_purple” android:orientation=”horizontal”/> <LinearLayout android:id=”@+id/viewB” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”0.4″ … Read more