question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setting background to Button has no effect

See original GitHub issue

after i fix my issue here #1649 and changing themr, my <Button> can not change his background Screenshot from 2020-08-24 17-50-50

when i change Theme of design tool to AppCompat i can see my new backgound

after search i found that i should change <Button> into <android.widget.Button>, why we need this

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fAntelcommented, Sep 3, 2020

@gabrielemariotti thank you very much 😃

1reaction
gabrielemariotticommented, Sep 3, 2020

@fAntel It is a different issue.

You can check in the Layout Inspector:

Schermata 2020-09-03 alle 13 59 27

In your case since you are using a Bridge Theme, you are working with an AppCompatButton.

You can use:

<com.google.android.material.button.MaterialButton
    style="@style/MainButton"
    android:id="@+id/button"
    android:layout_width="match_parrent"
    android:layout_height="wrap_content"
    android:layout_marginEnd="16dp"
    android:layout_marginStart="16dp"
    android:text="test"/>

or

    <style name="AppThemeBridge" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
        <item name="viewInflaterClass">com.google.android.material.theme.MaterialComponentsViewInflater</item>
    </style>

otherwise use the AppCompatButton and the android:background attribute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AndroidX Setting Background Color on Button has NO Effect
I use this in android x instead of <Button and background color will changes <androidx.appcompat.widget.
Read more >
Customize your background during a Microsoft Teams (free ...
Start or join your Teams meeting. In the pre-join screen, select the Background filters or Background effects The Background effects button button. In ......
Read more >
How to Change the Background Color of Button in Android ...
Step 1: Create a New Project · Step 2: Working with the activity_main.xml file · Step 3: Add a resource directory named as...
Read more >
ion-button - Ionic Framework
This property determines the background and border color of the button. By default, buttons have a solid background unless the button is inside...
Read more >
Button | Components - BootstrapVue
Note the type prop has no effect when either href or to props are set. ... In need of a button, but not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found