Home android button does not change the color set in selector

button does not change the color set in selector

Author

Date

Category

read all the answers to the tax question and still did not find the reason why this selector does not work for me. I tried all the selectors of all authors. The problem is that the button in the selector must change the color when pressed and simply when touching, and in not pressing mode there should be a specified color but it was not there.
My selector only cuts the alarm of the button in everything. Kenopka remains the color that is specified somewhere in the topics for the buttons and not in my selector.
Crp here’s selector

& lt; selector xmlns: android = "http://schemas.android.com/apk/res/android" & gt;
  & lt; Item Android: state_enabled = "false" & gt;
    & lt; shape android: shape = "rectangle" & gt;
      & lt; Corners Android: Radius = "16DP" / & gt;
      & lt; solid android: color = "# 41CD7E" / & gt;
    & lt; / shape & gt;
  & lt; / Item & gt;
  & lt; Item Android: state_pressed = "false" & gt;
    & lt; shape android: shape = "rectangle" & gt;
      & lt; Corners Android: Radius = "16DP" / & gt;
      & lt; Solid Android: Color = "# FF000000" / & gt;
    & lt; / shape & gt;
  & lt; / Item & gt;
  & lt; Item Android: state_pressed = "True" & gt;
    & lt; shape android: shape = "rectangle" & gt;
      & lt; Corners Android: Radius = "16DP" / & gt;
      & lt; solid android: color = "# AAA" / & gt;
    & lt; / shape & gt;
  & lt; / Item & gt;
& lt; / selector & gt;

This button

& lt; button
    Android: Text = "@ String / Sign_in"
    Android: TextColor = "@ Color / Text"
    Android: id = "@ + id / btn_sign_in"
    Android: background = "@ Drawable / Button_Selector"
    Android: layout_width = "Match_Parent"
    Android: layout_height = "wrap_content"
    Android: layout_margin = "30dp"
    App: layout_constrainttop_tobottomof = "@ + id / check_layout" & gt;
  & lt; / button & gt;

Skins still themes can in them the problem

& lt; resources xmlns: tools = "http://schemas.android.com/tools" & gt;
  & lt;! - Base Application Theme. - & gt;
  & lt; style name = "theme.productapp" parent = "theme.materialcomponents.daynight.noactionBar" & gt;
    & lt;! - PRIMARY BRAND COLOR. - & gt;
    & lt; Item Name = "ColorPrimary" & gt; @ color / card & lt; / item & gt;
    & lt; Item name = "ColorPrimaryVariant" & gt; @ color / background & lt; / item & gt;
    & lt; Item name = "ColoronPrimary" & gt; @ color / background & lt; / item & gt;
    & lt;! - Secondary Brand Color. - & gt;
    & lt; Item Name = "ColorSecondary" & gt; @ color / card & lt; / item & gt;
    & lt; Item Name = "ColorSecondaryVariant" & gt; @ color / background & lt; / item & gt;
    & lt; Item name = "Coloronsecondary" & gt; @ color / background & lt; / item & gt;
  & lt; / style & gt;
  & lt; style name = "splash" parent = "theme.materialcomponents.daynight.darkactionbar" & gt;
    & lt; Item name = "Android: WindowBackGround" & gt; @ Drawable / Back & Lt; / Item & gt;
  & lt; / style & gt;
& lt; / Resources & gt;

I think the problem is that somewhere the color of the button is default but where is the question. In the activat codes, I do not ask it for sure !!!

Changed in the ColorPrimary themes changes the color of the button. But it is not clear where it is set by default? Can it be viewbinging ???


Answer 1, Authority 100%

Your problem is imprisoned in the parent topic theme.materialcomponents.daynight.noactionBar
She does not make it easy to change the background markings.

To work your selector, you need to add to the markup of your button

app: backgroundtint = "# FFFFFF"
App: BackgroundtMode = "Multiply"

should turn out + – so

& lt; button
    Android: Text = "@ String / Sign_in"
    Android: TextColor = "@ Color / Text"
    Android: id = "@ + id / btn_sign_in"
    Android: background = "@ Drawable / Button_Selector"
    Android: layout_width = "Match_Parent"
    Android: layout_height = "wrap_content"
    Android: layout_margin = "30dp"
    App: layout_constrainttop_tobottomof = "@ + ID / Check_Layout"
    app: backgroundtint = "# FFFFFF" 
app: backgroundTintMode = "multiply" / & gt;
   & lt; / Button & gt;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions