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.
Related
I have this in my style.xml file
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<!--<item name="colorPrimary">#color/colorPrimary</item>-->
<!--<item name="colorAccent">#color/colorAccent</item>-->
<item name="android:windowBackground">#color/white</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="LoginScreenTheme" parent="AppTheme">
<item name="android:textColor">#color/white</item>
<item name="colorAccent">#color/white</item>
<item name="colorPrimaryDark">#color/login_background_dark</item>
</style>
<style name="LoginEditTextTheme" parent="AppTheme">
<item name="colorControlNormal">#color/login_edit_text_hint_color</item>
<item name="colorControlActivated">#color/login_edit_text_accent</item>
<item name="colorControlHighlight">#color/login_edit_text_accent</item>
<item name="android:textColorHint">#color/login_edit_text_hint_color</item>
<item name="android:textColorPrimary">#color/white</item>
</style>
<style name="LoginErrorFloatingLabelTheme" parent="TextAppearance.AppCompat.Small">
<item name="android:textColor">#color/login_error_floating_label_color</item>
</style>
<style name="ActionBarTheme" parent="AppTheme">
<item name="android:background">#color/home_primary_color</item>
</style>
<style name="LoginWaitingProgressBar" parent="AppTheme">
<item name="colorAccent">#color/orange_light</item>
</style>
</resources>
On devices with Lollipop and upper everything is alright, but on pre-lollipop there are wrong colors. It's look like theme is not applied to the devices with pre-lollipop android version. After googling I found that people are adviced to remove 'android:' prefix before every item in AppCompat theme but it doesn't work for me coz android studio doesn't see items after that.
The reason was that I didn't extend AppCompatActivity. When I changed it everything became okay.
colorPrimary , colorPrimaryDark and colorAccent items are available on only API 21+.If you want to apply them on pre lollipop devices you must move your current styles.xml file to values-v21 and create a new styles.xml on values folder and use the correct item for pre lollipop.
Check out android developers for more https://developer.android.com/guide/topics/ui/themes.html
This case is related to the following problem.
In the case I believe it may be a problem with the style I'm trying to use the toolbar. I need you to stay in the Toolbar overlay, it has a drawer menu, and the lollipop operate normally, lower some versions.
style.xml v21
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<item name="android:colorAccent">#color/accent</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<!-- enable window content transitions -->
<item name="android:windowContentTransitions">true</item>
</style>
style.xml
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowContentTransitions">true</item>
</style>
<style name="AppTheme" parent="AppTheme.Base">
</style>
If you are ok, someone could help me in this case the toolbar and the drawer disappear?
I found the solution to my problem. It was a possible conflict in style but rather a problem of organizing the objects on the screen.
With this following code could play the elements that disappeared in front of the camera.
getActivity().findViewById(R.id.DrawerLayout).bringToFront();
getActivity().findViewById(R.id.DrawerLayout).invalidate();
getActivity().findViewById(R.id.DrawerLayout).requestLayout();
In this case I have to get the reference of DrawerLayout and not the Toolbar. Thus the issue is resolved.
I have a problem changing background of my actionbar.
I am following the instructions on
https://developer.android.com/training/basics/actionbar/styling.html
however this does not change anything...
My ActionBar style
<style name="CustomActionBar" parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="android:background">#drawable/background</item>
<item name="background">#drawable/background</item>
<item name="displayOptions">showCustom</item>
</style>
My main application style is:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowBackground">#color/application_background</item>
<item name="actionBarStyle">#style/CustomActionBar</item>
<item name="windowActionBar">false</item>
</style>
And I have set that style to my application via manifest.
I have no idea what is wrong with my code.
Thanks for help
I was working hard to achieve this but I had no luck. What I tried to do is to change the background color from the style that I attached in my main style tag. This is my code:
<resources>
<style name="AppBaseTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item ></item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#2E495E</item>
</style>
Still nothing changed.
I get this in my application:
http://i.imgur.com/m1MrGwk.png
I had the same issue and it's probably the same problem you were having. Notice the docs say the following:
each style property that you declare must be declared twice..
So my issue was I declared it for 2.1 and up, but not for 3.0 and greater so my Galaxy S4 of course could not see any changes to the colours I was making.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<!--Support Library compatibility-->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#color/green</item>
<!--Support Library compatibility-->
<item name="background">#color/green</item>
</style>
<style name="NoActionBar" parent="Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
</style>
Is this the only style.xml you have? Else check if you are modifying
for the right API
I'm using the v7 support library in order to have an ActionBar on API Level 10+ (that's Android 2.3.3+). Now, I want to customize the look a bit, so I added an application theme. Excerpt of my values/styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/bg_actionbar</item>
</style>
This works fine on Android 2.3.3, where the compat stuff is used. However, on Android 4.3 on an N4 (or an emulator), the styles are not applied. If I change the styles.xml file to:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/bg_actionbar</item>
</style>
(notice the added android: prefix) it works on 4.3, but doesn't on 2.3 (styles not applied).
Is there any way I can get around this without specifying each <item> twice, once with the prefix and once without?
There is a perfect example on the google docs site:
http://developer.android.com/guide/topics/ui/actionbar.html#StyleExample
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="android:actionMenuTextColor">#color/actionbar_text</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
</style>
<!-- general styles for the action bar -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/TitleTextStyle</item>
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:backgroundStacked">#drawable/actionbar_background</item>
<item name="android:backgroundSplit">#drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/TitleTextStyle</item>
<item name="background">#drawable/actionbar_background</item>
<item name="backgroundStacked">#drawable/actionbar_background</item>
<item name="backgroundSplit">#drawable/actionbar_background</item>
</style>
<!-- action bar title text -->
<style name="TitleTextStyle"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
</style>
<!-- action bar tab text -->
<style name="TabTextStyle"
parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_text</item>
</style>
</resources>
Is there any way I can get around this without specifying each <item>
twice, once with the prefix and once without?
Another way would be to create version specific res/values-XX folders.
Since the divide is version 10 and versions 10+, you can create res/values-v10/styles.xml containing:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/bg_actionbar</item>
</style>
Let versions 10+ deal with the default res/values/styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/bg_actionbar</item>
</style>
Still, it isn't much different from specifying <item></item> twice.
For reference, you can look at the project structure of ActionBarSherlock. That should provide you some pointers.
You can also take a look at: Applying Styles and Themes to the UI. Scroll down to sub-section Select a theme based on platform version.
If I have not misunderstand your issue, you can collapse it together this way
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/ActionBarStyle</item>
<item name="actionBarStyle">#style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/bg_actionbar</item>
<item name="background">#drawable/bg_actionbar</item>
</style>
In my experience, this way eclipse gives compile time errors every time you change somethings inside styles.xml (due of lint if I remember good), but clean and rebuild make those errors go away.