Android无边框按钮 [英] Android borderless buttons

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

问题描述

我不想成为问这个问题的第三人,但以前的似乎尚未完全回答.android设计指南详细介绍了无边框按钮,但没有详细说明如何制作它们.在先前的答案之一中,建议使用:

I hate to be the third person to ask this, but the previous two askings haven't seemed to answer it fully. The android design guidelines detail borderless buttons, but not how to make them. In one of the previous answers, there was a sugestion to use:

style ="@ android:style/Widget.Holo.Button.Borderless"

这对于Holo主题来说效果很好,但是我也经常使用Holo.Light和

This works well for a Holo theme, but I use a lot of Holo.Light as well and

style ="@ android:style/Widget.Holo.Light.Button.Borderless"

似乎不存在.是否有办法在Holo.Light中为此类无边界按钮应用样式,或者更好的是,仅应用无边界标签而不指定其所属的主题,以便应用程序可以在运行时选择适当的样式?

Does not seem to exist. Is there a way to apply a style for such borderless buttons in Holo.Light, or better yet, simply apply a borderless tag without specifying which theme it belongs in, so the app can pick the proper style at runtime?

Holo.ButtonBar似乎很符合我的要求,只是它没有提供被按下的用户反馈.

Holo.ButtonBar seems to fit the bill for what I am looking for, except it provides no user feedback that it's been pressed.

此外,文档中是否有地方列出了可以应用的此类样式并对其进行了描述?无论我用多少谷歌搜索文档,我什么都找不到.如果我右键单击并编辑样式,则只有一个非描述性列表.

Also, is there a place in the documentation that lists such styles that can be applied and a description of them? No matter how much I google, and search through the docs, I can't find anything. There is just a non-descriptive list if I right click and edit style.

任何帮助将不胜感激.

从javram中得到了一个完美的答案,我想为有兴趣添加Google采用的部分边框的人添加一些XML.

Got a perfect answer from javram, and I wanted to add some XML for anyone interested in adding the partial borders google has adopted.

水平分隔线,效果很好

<View
    android:id="@+id/horizontal_divider_login"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:background="@color/holo_blue" />

这是一个垂直的:

<View
     android:id="@+id/vertical_divider"
     android:layout_width="1dip"
     android:layout_height="match_parent"
     android:layout_marginBottom="8dp"
     android:layout_marginTop="8dp"
     android:background="@color/holo_blue" />

推荐答案

此处查看我的答案.简而言之,正确的解决方案是使用以下方法:

Check out my answer here. In a nutshell the correct solution is to use the following:

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

这篇关于Android无边框按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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