5

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?

1 Answer 1

1

Try to replace this

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

with this

<style name="PreviousQuestionButtonStyle" parent="@android:style/ButtonBar">
Sign up to request clarification or add additional context in comments.

3 Comments

It doesn't look the same as ?android:attr/buttonBarButtonStyle
@android:style/ButtonBar doesn't produce the same result as android:attr/buttonBarButtonStyle. I wonder how this answer is marked correct.
For reasons I don't understand, this solution worked really well for me in my project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.