2018三月,发布了Android p 预览版。想了解具体变化可以查看 release notes 这里重点看下MD设计相关的内容
- 加入了新的主题
Theme.MaterialComponents
- 新添加Components
BottomAppBar
Chip
ChipGroup
MaterialButton
MaterialCardView
效果如下
compileSdkVersion 'android-P'
implementation"com.android.support:appcompat-v7:$support_version"
implementation"com.android.support:design:$support_version"
(ext.support_version = '28.0.0-alpha1')
BottomAppBar(官方说法是说BottomAppBar像是FloatingActionButton的摇篮(翻译的有点怪不过看效果好像有那么点意思)) Bottom App bar 是Toolbar一种拓展,配合FloatingActionButton使用,FloatingActionButton设置关联 到BottomAppBar,当然需要用到CoordinatorLayout作为它们的父级元素。- 要更改背景,您应该调用
app:backgroundTint而不是android:background setTitle,setSubTitle被覆盖不再起作用
- 要更改背景,您应该调用
ChipChipGroup标签和标签组Chip通过设置style="@style/Widget.MaterialComponents.Chip.Filter"style="@style/Widget.MaterialComponents.Chip.Action"style="@style/Widget.MaterialComponents.Chip.Choice"来决定Chip类型,ChipGroup可以设置为标签组为单选标签app:singleSelection="true"
MaterialCardView添加了添加了strokeColor,strokeWidth属性MaterialButton- 本身圆角按钮
app:cornerRadius - 图标按钮
app:icon可以控制图标位置和颜色 - 要更改背景,您应该调用
app:backgroundTint而不是android:background
- 本身圆角按钮