Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending an Attribute in Styles in Android

Tags:

android

I have a Button as follows:

  <Button
    android:id="@+id/previousQuestion"
    style="?android:attr/buttonBarButtonStyle"
    android:text="@string/questions_activity_previous_button"
    android:onClick="previousButton_OnClick"
  />

but I want to add more styling attribute which makes the Button hard to maintain later on so instead, I was going to put them into its own Style resource.

The question is "How am I going to still use ?android:attr/buttonBarButtonStyle?" I tried to do the following but didn't work:

<style name="PreviousQuestionButtonStyle" parent="android:attr/buttonBarButtonStyle">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_alignParentLeft">true</item>
</style>

Any ideas?

like image 464
Tarik Avatar asked Nov 11 '22 15:11

Tarik


1 Answers

Try to replace this

<style name="PreviousQuestionButtonStyle" parent="android:attr/buttonBarButtonStyle">

with this

<style name="PreviousQuestionButtonStyle" parent="@android:style/ButtonBar">
like image 114
Greg Ennis Avatar answered Nov 14 '22 23:11

Greg Ennis