美文网首页UI
com.google.android.material.butt

com.google.android.material.butt

作者: 小耗子_20da | 来源:发表于2021-03-01 16:54 被阅读0次

1、添加依赖
其实创建项目就带有了

implementation 'com.google.android.material:material:1.2.1'

2、常用属性

        app:icon="@mipmap/ic_launcher_round"//设置图标
        app:iconGravity="textStart"//图标重心,官网说有top和textTop,我这没有
        app:iconPadding="8dp"//图标与文字的距离
        app:iconTint="#0ff"//图标着色
        app:iconSize="48dp"//图标大小
        app:iconTintMode="add"//图标着色模式

        app:cornerRadius="64dp"//圆角角度
        app:rippleColor="#ff0"//水波纹颜色
        app:strokeColor="#f00"//描边颜色
        app:strokeWidth="1dp"//描边宽度

        //注意背景着色是 app: 不是android:
        app:backgroundTint="#8f0"//背景着色
        app:backgroundTintMode="add"//背景着色模式

        android:insetTop="8dp"//内凹距离,默认好像是6dp

        //如果想去除阴影,可以修改为该样式
        style="@style/Widget.MaterialComponents.Button.UnelevatedButton"

注意:theme要用 Theme.MaterialComponents.XXX

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

相关文章

网友评论

    本文标题:com.google.android.material.butt

    本文链接:https://www.haomeiwen.com/subject/krmafltx.html