ric*_*ert 75 android button material-design
如何实施谷歌材料设计指南中描述的"凸起按钮"和"平面按钮"?
凸起的按钮为大多数平面布局增加了尺寸.他们强调繁忙或宽阔空间的功能.

使用工具栏和对话框的平面按钮可避免过度分层.

资料来源:http://www.google.com/design/spec/components/buttons.html
Gab*_*iel 121
这需要Android 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>
Run Code Online (Sandbox Code Playgroud)
然后,您需要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>
Run Code Online (Sandbox Code Playgroud)
平面按钮
编辑:您应该遵循Stephen Kaiser给出的建议,而不是我以前对平面按钮的建议:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DONE"
style="?android:attr/borderlessButtonStyle"
/>
Run Code Online (Sandbox Code Playgroud)
编辑:如果您使用支持库,则可以使用在Pre-Lollipop设备上获得相同的结果style="?attr/borderlessButtonStyle".(注意没有android:)上面的例子就变成了
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DONE"
style="?attr/borderlessButtonStyle"
/>
Run Code Online (Sandbox Code Playgroud)
Ste*_*ser 84
为了实现平面按钮,您可以添加style="?android:attr/borderlessButtonStyle".
例:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DONE"
style="?android:attr/borderlessButtonStyle"
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
93751 次 |
| 最近记录: |