Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Botão não muda de cor com o botao_redondo

Ja testei e ja vi nos outros forums mas não esta indo, ele mantem a cor roxa, porem quando eu coloco o backgroundTint o aplicativo quebra, segue codigo do erro:

2021-06-23 14:53:30.749 31774-31774/com.example.aluraviagens E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.aluraviagens, PID: 31774
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aluraviagens/com.example.aluraviagens.ui.activity.ResumoPacoteActivity}: android.view.InflateException: Binary XML file line #88: Binary XML file line #88: Error inflating class Button
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: android.view.InflateException: Binary XML file line #88: Binary XML file line #88: Error inflating class Button
     Caused by: android.view.InflateException: Binary XML file line #88: Error inflating class Button
     Caused by: android.content.res.Resources$NotFoundException: Can't find ColorStateList from drawable resource ID #0x7f070097
        at android.content.res.ResourcesImpl.loadColorStateList(ResourcesImpl.java:1013)
        at android.content.res.Resources.loadColorStateList(Resources.java:1030)
        at android.content.res.TypedArray.getColorStateList(TypedArray.java:541)
        at android.view.View.<init>(View.java:5096)
        at android.widget.TextView.<init>(TextView.java:826)
        at android.widget.Button.<init>(Button.java:166)
        at android.widget.Button.<init>(Button.java:141)
        at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:75)
        at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:224)
        at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:220)
        at com.google.android.material.theme.MaterialComponentsViewInflater.createButton(MaterialComponentsViewInflater.java:43)
        at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:123)
        at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1563)
        at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1614)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.example.aluraviagens.ui.activity.ResumoPacoteActivity.onCreate(ResumoPacoteActivity.java:14)
        at android.app.Activity.performCreate(Activity.java:7009)
        at android.app.Activity.performCreate(Activity.java:7000)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
2021-06-23 14:53:30.749 31774-31774/com.example.aluraviagens E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
4 respostas

Codigo do Button:

<Button
        android:id="@+id/button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:backgroundTint="@drawable/botao_redondo"
        android:text="Realizar pagamento"
        android:textColor="@android:color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0" />

ps. a unica diferença é que eu troquei o botão pra botao_redondo, e se eu fizer as alterações diretamente no botão ele funciona normal(colocar a cor e o aredondamento diretamente no botão)

Oi João, de boa ?

Cara acho que tu usou a propriedade errada, no caso deveria usar o background e não o backgroundTint imagino ser esse o problema

Oi Matheus, eu verifiquei mas quando coloco background ele não aparece o estilo do botão, segue as imagens.

Tela do emulador rodando a app: https://ibb.co/Wx5czq4

Tela do preview com o codigo do botao https://ibb.co/wpWR6sm

solução!

Dá uma olhadinha nesse tópico : https://cursos.alura.com.br/forum/topico-renderizacao-de-background-cor-botao-153676