ユーザ用ツール

サイト用ツール


android:materialcomponentsforandroid

Material Components for Android

MaterialButton

Filled, elevated button (default)

style="@style/Widget.MaterialComponents.Button"

Filled, unelevated button

style="@style/Widget.MaterialComponents.Button.UnelevatedButton"

Outlined button

style="@style/Widget.MaterialComponents.Button.OutlinedButton"

Text button

style="@style/Widget.MaterialComponents.Button.TextButton"

Icon button

style="@style/Widget.MaterialComponents.Button.Icon"

style="@style/Widget.MaterialComponents.Button.TextButton.Icon"

使い方

build.gradle(Project)
    repositories {
        google() // ←確認
        jcenter()
 
    }
build.gradle(app)
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0-alpha1' // ←追加
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
activity_main.xml
    <com.google.android.material.button.MaterialButton
        android:textAppearance="@style/TextAppearance.MaterialComponents.Button"
        app:backgroundTint="@color/colorPrimary"
        android:id="@+id/buttonClear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_clear"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/imageView"
        app:layout_constraintTop_toTopOf="@+id/imageView" />

android/materialcomponentsforandroid.txt · 最終更新: 2019/10/23 22:43 by ips