How do I style buttons in a LinearLayout like a ListView

Posted by Mannaz on Stack Overflow See other posts from Stack Overflow or by Mannaz
Published on 2010-03-12T13:11:01Z Indexed on 2010/03/15 11:39 UTC
Read the original article Hit count: 849

I have a vertically orientated LinearLayout with some Buttons in it:

<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>

and I want this "List" of buttons to inherit the current style for ListView items. This is my current status of the stylesheet. The CKButton style gets applied over the Activity Theme.

<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">@drawable/button_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>

As you see I tried to draw the button background myself, but depending on the system default theme the background-color changes and therefore defining a static color is not an option. Is there a way to inherit the default ListView Row background within that buttons?

© Stack Overflow or respective owner

Related posts about android

Related posts about styles