Android的材料设计的按钮 - pre棒棒糖 [英] Android material design buttons - Pre lollipop

查看:180
本文介绍了Android的材料设计的按钮 - pre棒棒糖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何贯彻落实凸起按钮,并在谷歌的材料设计指南中规定的平键?

How do I implement the "raised button" and the "flat button" as described in google's material design guidelines?

募集按钮添加维度大体持平布局​​。他们强调>   在繁忙的或宽的空间功能。

Raised buttons add dimension to mostly flat layouts. They emphasize > functions on busy or wide spaces.

使用平面按钮的工具栏和对话,以避免过多的层次感。

Use flat buttons for toolbars and dialogs to avoid excessive layering.

来源:<一href="http://www.google.com/design/spec/components/buttons.html">http://www.google.com/design/spec/components/buttons.html

推荐答案

这需要的Andr​​oid 5.0

凸起按钮

继承Widget.Material.Button您的按钮样式,标准提升,提高操作将自动应用。

Inherit your button style from Widget.Material.Button, and the standard elevation and raising action will automatically be applied.

<style name="Your.Button" parent="android:style/Widget.Material.Button">
    <item name="android:background">@drawable/raised_button_background</item>
</style>

然后你需要创建一个 raised_button_background.xml 您的按钮的背景颜色提交纹波标签中:

Then you need to create a raised_button_background.xml file with your button's background color inside a ripple tag:

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?attr/colorControlHighlight">
    <item android:drawable="@color/button_color"/>
</ripple>

扁平按钮

编辑:对于平面按钮我的previous意见相反,你应该使用遵循以下斯蒂芬·凯泽给出的建议是:

Instead of my previous advice for flat buttons, you should instead use follow the advice given by Stephen Kaiser below:

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="DONE"
    style="?android:attr/borderlessButtonStyle"
/>

这篇关于Android的材料设计的按钮 - pre棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆