Android Enable Material Design Components

Setup

Edit app/module build.gradle.

android {
    compileSdkVersion 29

    defaultConfig {
        targetSdkVersion 29
    }
}

dependencies {
    implementation 'com.google.android.material:material:1.1.0'
}

NOTE: Compile with Android 9 / SDK 28

Activity

class MainActivity : AppCompatActivity() {}

NOTE: Use AppCompatActivity

Theme

Edit res/values/styles.xml

<resources>

    <!-- Base application theme. -->
    <!-- Theme.AppCompat.Light.DarkActionBar -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

NOTE: Material Components themes

Components

<com.google.android.material.chip.Chip
    android:id="@+id/batchStatusChip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Success"
    android:layout_gravity="right"
    app:chipBackgroundColor="@color/success_chip"
    android:textColor="@android:color/white"
    />

NOTE: List of Material Components

Specify Style

<TextView
    android:id="@+id/contentTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
    />

Reference:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.