There is a button:

android:background="@drawable/login_button" android:textColor="@drawable/transparent_button_text_color" 

In @drawable/login_button I made it so that the color of the button changes while the button is pressed, and in fact you need to change the text color
In @drawable/transparent_button_text_color wrote the following:

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="false" android:drawable="@color/white" /> <item android:state_pressed="true" android:drawable="@color/black" /> </selector> 

And here's the problem: in Design View, the color of the button is displayed in purple, and when I launch the application - an error
What am I doing wrong?

  • one
    Show the stack trace. - s8am
  • @ s8am `Binary XML file line # 30: Error inflating class Button - andrew

2 answers 2

You are most likely not referring there.

Try replacing android:drawable with android:color in the @drawable/transparent_button_text_color file.

    replace drawable with color Drawable these are pictures and Color is the color in the Xml file

    android: background = "@ drawable / login_button" android: textColor = "@ drawable / transparent_button_text_color"