2.8 KiB
{% contentfor benefits %}
-
Accurate & up to date
Implement Material Design with pixel-perfect components, maintained by Google engineers and designers
-
Latest Android APIs
Access components that use of the latest Android APIs and features, with graceful degradation for older Android versions
-
Industry standards
Take advantage of the same components used in Google’s Android apps, which meet industry standards for internationalization and accessibility
{% endcontentfor %}
Material Components for Android
Material Components for Android provides modular and customizable UI components to help developers easily create beautiful apps.
Getting Started
-
{: .step-list-item } ### 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.google.android.material:material:1.0.0' } -
{: .step-list-item } ### 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.)
<com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@id/fab" /> -
{: .step-list-item } ### Use the Component You can then reference that widget in your Java class. First import it,
import com.google.android.material.floatingactionbutton.FloatingActionButton;then use it.
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Do something! } }); -
{: .step-list-item } ### What's next?