0

When I place a button in a layout, it has a standard gray background. However I want to make it more like the kind of button you see in the Dialogs where it's a background-less button (e.g. the white buttons with text).

Like this

enter image description here

Not like this... not like this...

enter image description here

Community
  • 1
  • 1
Sean Hill
  • 1,297
  • 1
  • 13
  • 21
  • What did you try so far? Post your code! What happened when you ran it? What did you expect to happen instead? – Robert Sep 11 '16 at 02:37

3 Answers3

1

Old question but I just stumbled on it and have the answer (or at least I think), I really don't know if that's the best approach, but it should do the job.

<Button
    android:id="@+id/sign_in_button"
    style="@style/Widget.AppCompat.Button.Borderless.Colored"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

The trick here is the @style/Widget.AppCompat.Button.Borderless.Colored. Also see this answer, it explains a lot https://stackoverflow.com/a/36666660/1920068

Antonio Ribeiro
  • 373
  • 4
  • 12
0

try this

android:background="@android:color/transparent"
0

Just use a TextView instead, and put a click effect with the background:

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#23ac29"
        android:text="Signup"
        android:textSize="18sp"
        android:padding="8dp"
        android:background="?android:attr/selectableItemBackground"/>
Drilon Blakqori
  • 2,796
  • 2
  • 17
  • 25