Gabriele Mariotti d6973405b0 Updated MaterialTextView's documentation with the right package name of the component.
Resolves https://github.com/material-components/material-components-android/pull/541

GIT_ORIGIN_REV_ID=c9d1e674187c3fe23b7f209cbbbc8008e348592b
PiperOrigin-RevId: 266214327
2019-08-29 16:28:05 -04:00

2.0 KiB

Material Text View

A MaterialTextView is a derivative of AppCompatTextView that displays text to the user. To provide user-editable text, see {@link EditText}.

Design & API Documentation

Usage

Example code of how to include the component in your layout is listed here for reference.

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <TextView
      android:id="@+id/text_view_id"
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:text="@string/hello" />
</LinearLayout>

Note: If you use our full themes (which we recommend), TextView will auto-inflate to MaterialTextView, otherwise, you will need to specify <com.google.android.material.textview in your xml.

Attributes

MaterialTextView supports all of the standard attributes that can be changed for a AppCompatTextView. Unlike the AppCompatTextView which supports specifying the line height only in a view layout XML, MaterialTextView supports the ability to read the line height from a TextAppearance style, which can be applied to the MaterialTextView either using the style attribute or using the android:textAppearance attribute.

The following additional attributes can be changed in TextAppearance and applied to a MaterialTextView:

Feature Relevant attributes
Line Height android:lineHeight