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"
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"
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 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.
Any help would be appreciated.
Edit: Got a perfect answer from javram, and I wanted to add some XML for anyone interested in adding the partial borders google has adopted.
Fora horizontal divider, this works great
<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" />
and this for a vertical one:
<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" />
To change the default Button style of the application we can use the android:buttonStyle attribute in the AppTheme style inside the styles. xml.
Onclick in XML layout When the user clicks a button, the Button object receives an on-click event. To make click event work add android:onClick attribute to the Button element in your XML layout. The value for this attribute must be the name of the method you want to call in response to a click event.
Simply add the following style attribute in your Button
tag:
style="?android:attr/borderlessButtonStyle"
source: http://developer.android.com/guide/topics/ui/controls/button.html#Borderless
Check out my answer here. In a nutshell the correct solution is to use the following:
android:background="?android:attr/selectableItemBackground"
At the risk of beating a dead horse, here's another (possibly better) option. AppCompat v7 defines a borderless button style. If you're already making use of the AppCompat library, just go with that:
<Button android:text="@string/borderlessButtonText" style="@style/Widget.AppCompat.Button.Borderless" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With