如何实现谷歌材料设计指南中描述的“凸起按钮”和“平面按钮”?
凸起的按钮为大部分平面布局增添了维度。他们强调>
适用于繁忙或宽敞的空间。
对工具栏和对话框使用平面按钮以避免过多的分层。
Source: http://www.google.com/design/spec/components/buttons.html http://www.google.com/design/spec/components/buttons.html
这需要安卓5.0
凸起按钮
从 Widget.Material.Button 继承按钮样式,标准标高和提升操作将自动应用。
<style name="Your.Button" parent="android:style/Widget.Material.Button">
<item name="android:background">@drawable/raised_button_background</item>
</style>
然后你需要创建一个raised_button_background.xml
文件的波纹标签内包含按钮的背景颜色:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">
<item android:drawable="@color/button_color"/>
</ripple>
平按钮
编辑:您应该遵循下面 Stephen Kaiser 给出的建议,而不是我之前对平面按钮的建议:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DONE"
style="?android:attr/borderlessButtonStyle"
/>
编辑:如果您正在使用支持库,您可以通过使用在 Pre-Lollipop 设备上实现相同的结果style="?attr/borderlessButtonStyle"
。 (注意没有android:
) 上面的例子就变成了
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DONE"
style="?attr/borderlessButtonStyle"
/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)