如何创建无边界按钮在安卓 [英] How to Create Borderless Buttons in Android

查看:391
本文介绍了如何创建无边界按钮在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

href="http://developer.android.com/design/building-blocks/buttons.html"> Android的设计准则说,使用无边框按钮的How创建标准无边框按钮(如所提到的设计理念为指导)?并有标记为的答案的答案,但我还是输了,我不明白的方式将注释添加到一个问题,已经被关闭

The Android Design Guidelines say to use borderless buttons (see picture below), but don't really explain how. Someone asked this same question a few weeks ago here: How to create standard Borderless buttons (like in the design guidline mentioned)? and there was an answer marked as "the" answer, but I am still lost and I don't see a way to add comments to a question that has been "closed"

答案洱说

看入主题属性 buttonBarStyle ,    buttonBarButtonStyle borderlessButtonStyle

"Look into the theme attributes buttonBarStyle, buttonBarButtonStyle, and borderlessButtonStyle"

但我仍然无法弄清楚如何实际使用这些东西。我用Google搜索了一下周围,但没有找到任何东西,所以我想我只是问的问题一遍,希望有人能提供关于如何工作的更详细一点。

but I still can't figure out how to actually use those things. I Googled around a bit and couldn't find anything so I figured I'd just ask the question again, and hopefully someone can provide a little more detail on how this works.

推荐答案

我以为我已经解决了这个时候我看了这里几个星期前,发现回答有关使用一个透明的背景,但它不够好,因为它prevents从什么时候pressed被突出显示的按钮。

I thought I had this solved when I looked here a few weeks ago and noticed the answer about using a transparent background but it isn't quite good enough because it prevents the button from being highlighted when pressed.

此外,样式设置为 Widget.Holo.Button.Borderless ,因为它使按钮边界的大是不恰当的。

Also, setting the style to Widget.Holo.Button.Borderless isn't appropriate because it makes the button boundaries to big.

要弄清楚这一点,一劳永逸,我检查了Android源$ C ​​$ C为标准的日历应用程序,发现它使用了以下内容:

To figure this out once and for all, I check the android source code for the standard Calendar app and found that it uses the following:

android:background="?android:attr/selectableItemBackground"

这样做可以确保该按钮是无国界的的正确的大小。

这篇关于如何创建无边界按钮在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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