Material Components for Android
Material Components for Android provides modular and customizable UI components to help developers easily create beautiful apps.
Getting Started
-
Modify build.gradle
To use the Material Components library with the Gradle build system, include the library in the build.gradle dependencies for your app.
dependencies { compile 'com.android.support:design:[Library version code]' } -
Update your Layout
Add a reference to the component (widget) that you want to use in your XML layout. (You can also dynamically instantiate a widget in Java.)
<android.support.design.widget.FloatingActionButton android:id="@id/fab" /> -
Use the Component
You can then reference that widget in your Java class. First import it,
import android.support.design.widget.FloatingActionButton;then use it.
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Do something! } }); -
What’s next?