or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

buttons-and-selection.mdfeedback-and-communication.mdindex.mdinput-and-forms.mdlayout-and-containers.mdnavigation-components.mdpickers-and-selection.mdtheming-and-styling.md
tile.json

tessl/maven-com-google-android-material--material

Google's official Material Design components library for Android applications with comprehensive UI components, theming, and animations.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.google.android.material/material@1.14.x

To install, run

npx @tessl/cli install tessl/maven-com-google-android-material--material@1.14.0

index.mddocs/

Material Components for Android

Material Components for Android (MDC-Android) is Google's official implementation of Material Design components for Android applications. It provides a comprehensive library of UI components including buttons, cards, navigation elements, text fields, dialogs, and many others that follow Material Design guidelines. The library offers extensive theming capabilities, supports Material You dynamic color, includes advanced animations and transitions, and provides accessibility features out of the box.

Package Information

  • Package Name: com.google.android.material:material
  • Package Type: maven
  • Language: Java
  • Installation: Add to your build.gradle file:
    implementation 'com.google.android.material:material:1.14.0-alpha04'

Core Imports

import com.google.android.material.button.MaterialButton;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.textfield.TextInputLayout;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

Basic Usage

// Create a Material button
MaterialButton button = new MaterialButton(context);
button.setText("Click Me");
button.setIcon(getDrawable(R.drawable.ic_star));
button.setOnClickListener(v -> {
    // Show a snackbar
    Snackbar.make(v, "Button clicked!", Snackbar.LENGTH_SHORT).show();
});

// Create a Material card
MaterialCardView card = new MaterialCardView(context);
card.setStrokeWidth(2);
card.setStrokeColor(ContextCompat.getColor(context, R.color.stroke_color));
card.setCheckable(true);

// Create a text input field
TextInputLayout textInput = new TextInputLayout(context);
textInput.setHint("Enter your name");
textInput.setHelperText("This field is required");

Architecture

Material Components for Android is built around several key design patterns:

  • Material Theming: All components support Material Design theming through style attributes and theme overlays
  • Shape Theming: Components can be customized using ShapeAppearanceModel for consistent shape language
  • Color System: Built-in support for Material Design color roles and dynamic colors (Android 12+)
  • Motion System: Components include built-in animations following Material motion principles
  • Accessibility: All components include semantic accessibility support and screen reader compatibility
  • State Management: Consistent state handling across components (enabled, disabled, checked, selected, etc.)

Capabilities

Buttons and Selection Controls

Core input controls including buttons, chips, checkboxes, radio buttons, and switches with Material Design styling and behavior.

public class MaterialButton extends AppCompatButton {
    public MaterialButton(Context context);
    public void setIcon(Drawable icon);
    public void setIconTint(ColorStateList iconTint);
    public void setStrokeColor(ColorStateList strokeColor);
    public void setStrokeWidth(int strokeWidth);
    public void setCornerRadius(int cornerRadius);
}

Buttons and Selection Controls

Navigation Components

Navigation elements including bottom navigation, navigation drawer, navigation rail, tabs, app bars, and search components for organizing app structure.

public class BottomNavigationView extends NavigationBarView {
    public BottomNavigationView(Context context);
    public void setOnNavigationItemSelectedListener(OnNavigationItemSelectedListener listener);
    public Menu getMenu();
    public void setSelectedItemId(@IdRes int itemId);
}

Navigation Components

Input and Forms

Text input components, sliders, and form-related elements for collecting and validating user input.

public class TextInputLayout extends LinearLayout {
    public TextInputLayout(Context context);
    public void setHint(CharSequence hint);
    public void setError(CharSequence error);
    public void setHelperText(CharSequence helperText);
    public EditText getEditText();
}

Input and Forms

Layout and Containers

Container components including cards, sheets, app bars, and layout utilities for organizing content.

public class MaterialCardView extends CardView {
    public MaterialCardView(Context context);
    public void setStrokeColor(@ColorInt int color);
    public void setStrokeWidth(@Dimension int strokeWidth);
    public void setCheckable(boolean checkable);
    public void setChecked(boolean checked);
}

Layout and Containers

Feedback and Communication

Components for providing feedback including snackbars, dialogs, progress indicators, badges, and tooltips.

public class Snackbar extends BaseTransientBottomBar<Snackbar> {
    public static Snackbar make(View view, CharSequence text, int duration);
    public Snackbar setAction(CharSequence text, View.OnClickListener listener);
    public Snackbar setActionTextColor(@ColorInt int color);
    public void show();
}

Feedback and Communication

Pickers and Selection

Date and time pickers with Material Design styling for temporal data selection.

public class MaterialDatePicker<S> extends DialogFragment {
    public static Builder<Long> datePicker();
    public static Builder<Pair<Long, Long>> dateRangePicker();
    public S getSelection();
    public void addOnPositiveButtonClickListener(MaterialPickerOnPositiveButtonClickListener<S> listener);
}

Pickers and Selection

Theming and Styling

Comprehensive theming system including colors, shapes, elevation, and dynamic theming support.

public class MaterialColors {
    public static int getColor(Context context, @AttrRes int colorAttributeResId, int defaultValue);
    public static ColorStateList getColorStateList(Context context, @AttrRes int colorAttributeResId);
    public static int layer(@ColorInt int backgroundColor, @ColorInt int overlayColor, @FloatRange float overlayAlpha);
}

Theming and Styling

Core Types

// Shape appearance for customizing component shapes
public class ShapeAppearanceModel {
    public static Builder builder();
    public CornerTreatment getTopLeftCorner();
    public CornerSize getTopLeftCornerSize();
}

// Color state lists for component theming
public interface ColorStateList {
    int getColorForState(int[] stateSet, int defaultColor);
}

// Common listener interfaces
public interface OnNavigationItemSelectedListener {
    boolean onNavigationItemSelected(@NonNull MenuItem item);
}

public interface OnClickListener {
    void onClick(View v);
}

Constants

// Animation modes
public static final int ANIMATION_MODE_SLIDE = 0;
public static final int ANIMATION_MODE_FADE = 1;

// Label visibility modes
public static final int LABEL_VISIBILITY_AUTO = -1;
public static final int LABEL_VISIBILITY_SELECTED = 0;
public static final int LABEL_VISIBILITY_LABELED = 1;
public static final int LABEL_VISIBILITY_UNLABELED = 2;

// Snackbar durations
public static final int LENGTH_INDEFINITE = -2;
public static final int LENGTH_SHORT = -1;
public static final int LENGTH_LONG = 0;