Although I'm using dark action bar, back arrow color is black.
I declared theme as below in manifest :
android:theme="#style/Theme.AppCompat.Light.DarkActionBar
and screenshot :
Back arrow color should be white. How can I do this ?
One option is to set your own indicator
<style name="Example.Theme" parent="#android:style/Theme.Holo.Light" >
<item name="android:homeAsUpIndicator">#drawable/up_indicator</item>
</style>
Related
I need to set navigation back button dynamically
when I do this `
viewBinding.toolbar.navigationIcon?.setColorFilter(Color.parseColor(theme.primaryTextColor), PorterDuff.Mode.MULTIPLY)
it doesn't effect changing color or if I do
viewBinding.toolbar.setNavigationIcon(R.drawable.ic_back) in MainActivity
where ic_back is white back button it doesn't work it shows back button
or if I add this app:navigationIcon="#drawable/ic_back" in xml it doesn't work
but when I set app:theme="#style/ToolbarColoredBackArrow"
<style name="ToolbarColoredBackArrow" parent="AppTheme">
<item name="android:textColorSecondary">#FFFFFF</item>
</style>
it works why? I should do this without using theme
If the toolbar is your support action bar, then this definitely works :
toolbar.setNavigationIcon(R.drawable.ic_back);
Or whatever you want to set the icon to, just that it has to be a drawable file.
I have an application with a lot of activities, that all use the same theme:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#aaa</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Activities all have action bar looking like by the lines of:
What I just can't figure out is, how to color action buttons (pencil on the right) to black.
Essentially I want to have white action bar (on screenshot is white just for action button to be visible) with black title, back arrow and action buttons, but I don't want to add Toolbar view to every activity I have.
So, is there a way to color action buttons black by XML?
Create vector icons for your menu items and set their color to black (in your case you won't need to set their color as they are black by default). To create vector asset go to File - New -Vector Asset.
You can also download an icon from the internet as svg file and import it through vector asset creating dialog.
The list of default icons is also available here.
I'm try to developing an app with a navigation drawer from a template found on github.
In style.xml i have:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#ff0000</item>
<item name="colorPrimaryDark">#0000ff</item>
and the status bar in navigation drawer is ok.
When i click the button it runs this command:
getWindow().setStatusBarColor(Color.GREEN);
Now the status bar color in navigation drawer is no more translucent
How restore status bar color to translucent?
The difference is that the xml defined colors colorPrimary and colorPrimaryDark are not really used to directly set the status bar color.
Actually the statusbar is completely transparent all the time and only the underlaying View is colored. Thats why it can have another color on the left than on the right side (have a look at your second screenshot). If you now call getWindow().setStatusBarColor(..) you indeed color the statusbar directly and over-draw the color of both Views. So it needs to stay transparent!
What you really want to do, is changing the color of the View underlaying the status bar, which is done with the ScrimInsetsFrameLayout class.
Have a look at this question and this class from the library you provided
There you should find all the necessary information to change only the color of the area you want to.
In case you really just want to reset the color:
getWindow().setStatusBarColor(Color.TRANSPARENT);
I had changed Action Bar color with this code: getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0067ad")));
But when I hold Home button there Action Bar Color is Black.
How I can change it!
Thanks!
You'd better set color of Actionbar in styles-v21.xml like following:
<item name="android:colorPrimary">#color/yourActionbarColor</item>
colorPrimary determines the color of Actionbar and app's header in recents. In styles.xml focused on pre-L versions, you should use name="colorPrimary" to get same result.
And if you only want to change header color shown in recents above Lollipop, you can use following java code:
TaskDescription taskDesc = new TaskDescription(yourTitle, yourIcon, yourColor);
myActivity.setTaskDescription(taskDesc);
First, a few words about the app : minimum level is 16, I use a DrawerLayout (with the indicator) and have changed the background of my ActionBar.
When clicking on the home button to open the drawer, there is a blue pressed effect on both the image and the drawer indicator, that I'd like to remove. I tried setting selectableItemBackground in the styles to transparent, nearly everywhere I could think of, but that doesn't seem to change anything. Do anyone have a solution ?
Here is the image of this effect I'd like to remove :
Here is the styles.xml part for the ActionBar I'm using :
<style name="ActionBar.Solid.Bnp" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/action_bar_green</item>
<item name="android:titleTextStyle">#style/ActionBar.Title</item>
<item name="android:actionBarItemBackground">#null</item>
</style>
and finally the drawable used for background.
selectableItemBackground is close, but you need to use the actionBarItemBackground attribute instead.
For instance:
<style name="Your.Theme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#null</item>
</style>
You should keep in mind that the system uses this attribute in the ActivityChooserView too, which is what the ShareActionProvider returns in ActionProvider.onCreateActionView.
To highlight all this, here are the results when you use #android:color/holo_red_light instead: