1. 简介
Design Support Library是Google在2015年的IO大会上发布的全新Material Design支持库,在这个support库里面主要包含了 8 个新的 Material Design组件,最低支持 Android 2.1。
安卓的需要:implementation ‘com.android.support:design:28.0.0’
安卓X的不需要

2.使用
TextInputLayout
布局文件
1 <android.support.design.widget.TextInputLayout
2 android:id="@+id/layout_account"
3 android:layout_width="match_parent"
4 android:layout_height="wrap_content"
5 android:layout_marginLeft="20dp"
6 android:layout_marginRight="20dp"
7 android:layout_marginTop="60dp">
8
9 <EditText
10 android:layout_width="match_parent"
11 android:layout_height="wrap_content" />
12
13 </android.support.design.widget.TextInputLayout>
在EditText中设置textColorHint属性是没有效果的,textColorHint会根据Theme的颜色来显示,只能通过设置Activity的Theme来更改hint的颜色。
•TextInputLayout包裹EditText,注意:TextInputLayout只能有一个子控件
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
2 <item name="colorPrimary">@color/colorPrimary</item>
3 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
4 <item name="colorAccent">@color/colorAccent</item>
5 <item name="android:textColorHint">@color/color_333333</item>
6</style>
属性:
app:counterEnabled="true" //设置是否显示字数统计
2app:counterMaxLength="15" //设置字数统计的最大值
3app:counterOverflowTextAppearance="@style/counterOverFlowAppearance" //设置超出最大值后的样式
4app:counterTextAppearance="@style/counterAppearance"
SnackBar:
最普通的SnackBar,只有文字说明,复杂的SnackBar可以带按钮及事件。
Snackbar.make(v, "谢谢浏览我的博客", Snackbar.LENGTH_SHORT).show(); //和Toast很像
其余可以点击连接继续观看
本文借鉴于https://blog.youkuaiyun.com/Fly_li_sir/article/details/79704021
本文详细介绍Google在2015年发布的DesignSupportLibrary,该库包含8个MaterialDesign组件,最低支持Android2.1。文章深入讲解了TextInputLayout的使用方法,包括布局文件配置、hint颜色设置及主题应用。同时,介绍了SnackBar的使用方式,为开发者提供全面的MaterialDesign组件指南。
956

被折叠的 条评论
为什么被折叠?



