change homeAsUpIndicator icon in android kitkat - android

I tried to change the default icon of HomeAsUpEnabled by editing my styles.xml file. But my icon did't changed. I am working on min sdk version:23. Below is my styles.xml file.
My styles.xml file
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:homeAsUpIndicator">#drawable/back</item>
<item name="homeAsUpIndicator">#drawable/back</item>
</style>

Use the Toolbar and call toolbar.setNavigationIcon(). See more on toolbar here http://developer.android.com/reference/android/widget/Toolbar.html

Related

Another "Failed to load AppCompat ActionBar with unknown" error issue

I cannot see my layouts in the layout editor. The error message is whats in the title.
Not sure how many of these topics need to exist and why Android is such a black hole when it comes to issues, but I'm still having problem with this:
This project uses:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v13:28.0.0'
What I have in my styles file:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="colorControlNormal">#color/menu_yellow</item>
<item name="colorControlActivated">#color/menu_yellow</item>
<item name="colorControlHighlight">#color/menu_yellow</item>
</style>
So the idea was to replace it to Base.Theme.AppComat.Light based on other answers:
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light">
<!-- Customize your theme here. -->
...
</style>
Now this just gives me a "resource not found (Base.Theme.AppCompat.Light)"
Either way I have tried a lot of suggested solutions back from 28 alpha but none of them work now with released 28.
try this way
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="colorControlNormal">#color/menu_yellow</item>
<item name="colorControlActivated">#color/menu_yellow</item>
<item name="colorControlHighlight">#color/menu_yellow</item>
</style>
maybe this help you
in the styles.xml replace
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
with
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

Unable to change Navbar Color

I tried so many things to change the navbar colour such as
Android lollipop change navigation bar color
android change navigation bar color
How to change system navigation bar color
Nothing works
I added the item to styles.xml - using Android 8.1
<item name="android:navigationBarColor">#color/theme_color</item>
Anyone knows what is the best way to do this in Xamarin.Android
UPDATE: I tried the following code in my style file
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="color">#color/red</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
While fixing another issue I had to change and minimum API level to
Lollipop and noticed that
<itemname="android:navigationBarColor">#color/theme_color</item>
started working when minimum API level is set to Lollipop.
So I think for some reason Xamarin requires to use use Minimum API version Lollipop for this to work
This works for me.
You need to create a new style for drawer toggle like this:
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">#color/white_color</item>
</style>
And add this to your preferable style.
<style name="NoActionbarTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/primary</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
And finally use NoActionbarTheme theme in manifest file within your Activity.
Hope it will help you.

Theme.AppCompat.NoActionBar color setup

When I use this theme everything is OK.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
But I wanted to use custom toolbar so I changed app theme to Theme.AppCompat.NoActionBar.
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
The problem is that background of app now has the same color as a toolbar.
Before this change it was white.
When I change android:windowBackground it's only apply to Navigation Drawer.
How to make background color (marked by red arrow) white again ?
You need to change background color from xml file
and try this style for no actionbar
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="android:typeface">monospace</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">#color/colorPrimary</item>
<item name="android:textSize">#dimen/common_text_size</item>
</style>
Solved the issue by changing only colorPrimary.
<style name="AppTheme.NoActionBar">
<item name="colorPrimary">#color/colorWhite</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

How to change the theme of contextual action bar

I have use toolbar in my app with style
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/holo_blue</
<item name="actionModeStyle">#style/Search.ActionMode</item>
<item name="windowActionModeOverlay">true</item>
</style>
Then I used a contextual action bar and able to change the background color.
<style name="Search.ActionMode" parent="#style/Widget.AppCompat.ActionMode">
<item name="background">#color/actionModeColor</item>
</style>
But I am unable to change the background color of popup menu.
Here is the image
And I wanted the background color of popup menu to be white. I also tried to change the theme by Widget.AppCompat.Light.ActionBar in Search.ActionMode but it does nothing.
There is an easy way to change the colors in Actionbar Use ActionBar Generator:
http://jgilfelt.github.io/android-actionbarstylegenerator/
and copy paste all file in your res folder and change your theme in Android.manifest file.
I have faced the same problem as yours. What I did is
I changed from
<!-- Base application theme. -->
<style name="Theme.Noteplus.Base.Brown" parent="Theme.AppCompat.Light.NoActionBar">
<item name="actionModeStyle">#style/Widget.ActionMode</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
to
<!-- Base application theme. -->
<style name="Theme.Noteplus.Base.Brown" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionModeStyle">#style/Widget.ActionMode</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
solve the problem. (Not exactly sure the reason behind)
(https://stackoverflow.com/a/50114013/72437)

what's the difference between windowActionBar and android:windowActionBar

when I set thestyle in this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
the actionbar will go away.
however,when I set it in this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowActionBar">false</item>
<item name=“android:windowNoTitle">true</item>
</style>
the actionbar is still here.
what's the difference ?
windowActionBar is an attribute provided in AppCompat library, where as android:windowActionBar is provided in Material theme.
The action bar is going away when you set below code, just because you are using AppCompat library and referring the attribute provided in this library itself:
<item name="windowActionBar">false</item>
On another points, it's same as colorPrimary and android:colorPrimary attribute and all other similar attributes.
For example:
We were using Material theme and referring android:colorPrimary attribute as below:
<style name="AppTheme" parent="android:Theme.Material.Light">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
....
....
</style>
but we are now using AppCompat library with only colorPrimary attribute, for providing compatibility to lower versions.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
...
...
</style>
android:windowActionBar denotes property for lollipop and above only. Where as windowActionBar denotes for all versions and is retrieved from support library.

Categories

Resources