Main Activity Support Action Bar Buttons

Viewed 23

I'm in Kotlin using the default Action Bar in the main activity:

setSupportActionBar(binding.toolbar)

I see that there are several elements controlling the color of the Title, it's background, the toolbar background and the buttons on the bar. There must be a way to set the entire toolbar one color and the buttons another color. I'm using styling and XML and code to set a lot of colors elsewhere for day/night modes but I can't change the colors of these buttons. Code takes precedence over all and so I prefer Kotlin code. But it doesn't cover everything like the styling XML code does.

EDIT by author August 18, 2022:

Possibly last comment here because this is not possible. One writer here in SO admitted it was easier to build toolbars in each fragment with independent buttons than use the default main activity toolbar. I've done that with success and in adding the ability to slide between fragments but that is not what I think the compiler designers would have hoped for.

With the main activity toolbar, the buttons come from vector assets with their own XML files. If the fill color is changed in those files with this:

android:tint="?attr/colorControlNormal

and this in for example a night theme:

<item name="android:colorControlNormal">@color/yellow_text</item>

I can't get the colors in a button to change at all.

It's the same as in checkbox properties where the background of the checkbox background is tied to the background of the actual background of the "form" itself showing as a page (the main activity and fragment) on an Android. I can't change the background color of the tick mark in the checkbox either. A default seems to be taking over in the day/night themes.

0 Answers
Related