I was just checking the design guidelines and wondering about the borderless buttons. I goggled and tried to find in the source but can't bring it together by myself. Is this the normal Button widget but you add a custom (Android default) style? How to make these borderless buttons (of course you can set the background to empty, but then I don't have the divider)?
Here links to the design guidelines:
Adding on to the top answer you can also use views with a dark gray background color in a Linear Layout like so.
If your line is horizontal you'll want to set the height to 1dip and the width to match the parent and vice-versa if your line is vertical.
Try this code, to remove the background drawable (@drawable/bg) programmatically, just we need to provide null as a parameter.
For some reason neither
style="Widget.Holo.Button.Borderless"
norandroid:background="?android:attr/selectableItemBackground"
worked for me. To be more preciseWidget.Holo.Button.Borderless
did the job on Android 4.0 but didn't work on Android 2.3.3. What did the trick for me on both versions wasandroid:background="@drawable/transparent"
and this XML in res/drawable/transparent.xml:Plain head through the wall approach.
For the one who want borderless buttons but still animated when clicked. Add this in the button.
If you wanted a divider / line between them. Add this in the linear layout.
Summary
A great slide show on how to achieve the desired effect from Googles Nick Butcher (start at slide 20). He uses the standard android
@attr
to style the button and divider.From the iosched app source I came up with this
ButtonBar
class:This will be the
LinearLayout
that the "OK" and "Cancel" buttons go into, and will handle putting them in the appropriate order. Then put this in the layout you want the buttons in:This gives you the look of the dialog with borderless buttons. You can find these attributes in the res in the framework.
buttonBarStyle
does the vertical divider and padding.buttonBarButtonStyle
is set asborderlessButtonStyle
for Holo theme, but I believe this should be the most robust way for displaying it as the framework wants to display it.