首页 > 移动平台 > 详细

Android 配置Material Design库及使用MaterialButton

时间:2021-05-12 20:30:44      阅读:20      评论:0      收藏:0      [点我收藏+]

Android 配置Material Design库
1.首先在gradle.build文件中添加依赖

implementation ‘com.android.support:design:29.0.2‘
1
添加后的gradle文件如下,多的可删可不删

ependencies {
implementation fileTree(dir: ‘libs‘, include: [‘*.jar‘])
implementation ‘androidx.appcompat:appcompat:1.0.2‘
implementation ‘com.android.support:design:29.0.2‘
}
1
2
3
4
5
2.更换AndroidManifest文件中的Theme,也就是value/style中的AppTheme属性,如果不修改这个,使用的组件就只有最基本的效果,比如MaterialButton就没有水波纹的效果

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
1
3.在需要使用Material组件的layout文件中添加

xmlns:app="http://schemas.android.com/apk/res-auto"
1
如果有的话就不用加了

4.最后给出一个MaterialButton的代码,如果能跑起来并切有水波纹效果就说明配置成功了

<com.google.android.material.button.MaterialButton
android:layout_width="200dp"
android:layout_height="60dp"
android:gravity="center"
android:text="MaterialButton"
android:textColor="#ffffffff"
android:textSize="24sp"
app:backgroundTint="#FFA54C" /> 
5.配置完以后,如果写代码没有自动补全什么的,可以试着Build 一> Rebuild Project一下


————————————————
版权声明:本文为CSDN博主「Alrey_」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_17282141/article/details/105622969

Android 配置Material Design库及使用MaterialButton

原文:https://www.cnblogs.com/javalinux/p/14759950.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!