0

I have the following Button in my app:

Button as it's meant to be

Described by this code:

<Button
    android:id="@+id/button_next"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/colorAccent"
    android:padding="24dp"
    android:text="@string/next_question" />

But I was getting the following warning:

Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent)

So I inserted this line (as advised here on stackoverflow) :

style="?android:attr/borderlessButtonStyle"

Now the background of the button vanished.

Button after background vanished

How to keep the first appearance removing the warning I was getting?

Community
  • 1
  • 1
Robb1
  • 4,587
  • 6
  • 31
  • 60
  • If you click on the line with the warning in your xml file, press `Alt` and `Enter`, you should have an option called `Disable inspection` or `Supress:...`. – yennsarah Jan 10 '17 at 09:07
  • @Amylinn is that really the only option I have? I would like to find a way to fix the problem before considering to totally ignore it. – Robb1 Jan 10 '17 at 09:09
  • If all u want is to show a text with a background color, why use a button. Button extends text view. The only extra stuff the button has is the inbuilt background click effects(elevation on click etc). If you dont want that, use a textview instead and you wont see any more working. This warning is correct... – amalBit Jan 10 '17 at 09:11
  • @amalBit that's the point: I want that! I need a *Button*. (With click effect included). – Robb1 Jan 10 '17 at 09:12
  • The warning should be irrelevant if you already achieved the layout you want - it simply tells you, that you are (maybe) violating the design guidelines. Have you tried to follow what the warning suggests? How did that look? – yennsarah Jan 10 '17 at 09:15

0 Answers0