Tarik
Tarik

Reputation: 81831

Extending an Attribute in Styles in 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?

Upvotes: 5

Views: 1175

Answers (1)

Greg Ennis
Greg Ennis

Reputation: 15381

Try to replace this

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

with this

<style name="PreviousQuestionButtonStyle" parent="@android:style/ButtonBar">

Upvotes: 1

Related Questions