views:

771

answers:

1

I have some buttons orientated in a vertical LinearLayout with the default menuitem_background applied to them (Which gives them a transparent background at default state and a highlighting color on click/press).

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">  
    <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt1" android:text="Button 1"></Button> 
    <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt2" android:text="Button 2"></Button>
    <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt3" android:text="Button 3"></Button> 
    <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt4" android:text="Button 4"></Button> 
</LinearLayout>

I want each of the buttons to have a border at the bottom. How do I achieve this?

This is the style applied to the buttons:

<style name="CKButton" parent="android:style/Widget.Button">
    <item name="android:textSize">21sp</item>
    <item name="android:layout_margin">0dip</item>
    <item name="android:background">@android:drawable/menuitem_background</item>
    <item name="android:textColor">@color/button_text_normal</item>
    <item name="android:padding">10dip</item>
    <item name="android:gravity">left|center_horizontal</item>
</style>
A: 

Assuming you want to put a dividing line between your buttons, you can do it with a View like follows, in between the buttons in your LinearLayout:

<View android:layout_height="2dp" android:layout_width="fill_parent" android:background="#000"/>

That would give you a black line 2dp high. Perhaps add in some margins if you want gaps between it and the buttons with android:layout_margin, but that's an easy way to do it. It might be possible to do that directly in the style, but you'd probably have to modify the background 9-patches used by the menuitem_background style.

Steve H
That was a thougt I already had, but is unfortunately not an option. There are over 100 of these Buttons spread over dozens of layouts.And I'm also not able to make a custom 9-patch because the system default colours have to be used.
Mannaz
Hmm, I'm not sure what you can do then. Sorry!
Steve H