I have defined
<item name="android:statusBarColor">#color/some_color</item>
<item name="android:navigationBarColor">#color/some_color2</item>
and it works well in emulator with API 22 but in my Huawei with the same Android version status bar and navigation bar color not works. It remains the same like before.
I can add that another attributes like android:textApperance or android:background works fine there is a problem just with those two.
Place this is your values/styles.xml
<style name="MyMaterialTheme" parent="Theme.AppCompat.Light">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#color/my_awesome_color</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#color/my_awesome_darker_color</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#color/accent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight & colorSwitchThumbNormal. -->
</style>
and set this theme to your Activity in manifist
like this
<activity
android:name=".MainHomeFragmentActivity"
android:theme="#style/MyMaterialTheme" />
Huawei has not implemented in EMUI 3.1 based on Lollipop 5.1.1 which have colors of status bar. So there are 2 ways to solve it.
1-)
The files you need:
[emui3.1.png https://drive.google.com/file/d/0BwQ4XeikVQ3kU2ZNVW53UFQ4WDQ/view?usp=sharing]
[emui3.1bg.png https://drive.google.com/file/d/0BwQ4XeikVQ3kVnh5UTBrS3F4aW8/view?usp=sharing]
This is an EMUI theme from EMUI offical BBS(this theme works well but without Translucent Status Bars): https://drive.google.com/file/d/0BwQ4XeikVQ3kRmdSZ19LblpiQ00/view?usp=sharing
HUAWEI LAUNCHER
Download any Huawei theme and get .hwt file.
Use any unzip sofaware and unzip it.
Put emui3.1bg.png into it(I think you will now how to do it.), then zip again, make sure it likes before(Well, added a photo...), change its name to XXX.hwt
Put the new .hwt into (NOT SDCARD1) /sdcard/HWThemes(if there is not it, you must create one)
Open THEMES APP on your EMUI phone and change to the theme you changed before.
Open emui3.1.png with system library, and set it to the launcher wallpaper.
It maybe works, if not, do 1-6 again.
Here is a tutorial: https://www.youtube.com/watch?v=HTweBQgjXr8
2-) You need to root your device. You can check here to root : https://www.kingoapp.com/root-huawei.htm
then [https://drive.google.com/file/d/0BwQ4XeikVQ3kZGJDMWpuSGF0bDA/view?usp=sharing] just flash this zip
Related
I have an app in which the user can choose between the default theme and a dark theme. The manifest applies AppTheme to the <application>, while each activity checks the relevant flag and uses setTheme(AppTheme.Dark) if necessary.
This implementation works well for all my activities, but the preview window shown by the OS before the application launches uses the Manifest theme, i.e. the light one. So users get a sudden white screen before reaching the dark app.
Based on other SO answers, I gathered that the only customization we can do is to set a windowBackground drawable for the window to use (and a statusBarColor if needed).
Even though I have two different windowBackground set for each theme, I can't change the theme for the preview window since the Application class seems to load after it, and setting theme there makes no difference.
I'd like to avoid disabling the preview since it adds a noticeable delay without much indication that the app is launching. Is there any solution to this? I'm considering having a dark color for both themes in the worst case, like the Reddit app does.
Styles:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- primary and accent color attributes -->
<item name="android:windowBackground">#color/activityBackgroundLight</item>
</style>
<style name="AppTheme.Dark" parent="AppTheme">
<!-- primary and accent color attributes -->
<item name="android:windowBackground">#color/activityBackgroundDark</item>
</style>
Note: While I'm using colors here, I've already tried with a gradient drawable and it doesn't change anything.
UPDATE: I wasn't able to get any other method, so I went ahead and applied the dark theme by default on the SplashActivity. This means the preview window is always dark, while the check in the SplashActivity's onCreate is inverted (compared to other activities) and applies the light theme if needed.
Still looking for a solution that actually lets me switch at runtime.
How can I change the color of the animation?
The color is based on your accentColor in your AppTheme.
To change it, change your AppTheme (generally in res/values/styles.xml) to:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">#F00</item> <-- change to color
<!-- Status Bar color -->
<item name="colorPrimaryDark">#000</item>
<!-- Details color -->
<item name="colorAccent">#000</item>
</style>
Beware it's an global app change, every scrollview bounce animation will have this color.
To change only the overflow animation color, use android:colorEdgeEffect. Otherwise it will be inherited from the colorPrimary in AppTheme.
The accepted answer should be changed to specify colorPrimary instead of colorAccent.
See answer here: android lollipop scrollview edge effect color
Put this inside android/app/src/res/values/styles.xml
<item name="android:colorEdgeEffect">#E53644</item>
if someone is using expo managed app, it's not supported by expo yet, but there's a workaround.
you'd need to expo eject -> to transition to bare workflow. then as said above within android/app/src/res/values/styles.xml add
<item name="android:colorEdgeEffect">#E53644</item>.
now the worst part which took me hours to figure out - you'll have 2 themes generated by default the AppTheme and Theme.App.SplashScreen, it didn't work until I've added it to splashscreen one :/. I've added it to both themes just in case. note that this specific change will work only when you run android specific native build npm run android, for more please read this
I'm using Expo managed workflow + react native paper with Material UI v3 and in debugging the color of the "ripple" was purple.
But luckily, when I test it over the Google Play Store, it was based on the primary color (or primary container color).
PS: I had similar issues with the color of dialog buttons and the app icon being not shown correctly.
The "Rendering problem" states Couldn't resolve resource #style/Widget.Holo.Actionmode but when I do a project/path search for Widget.Holo.Actionmode it isn't there.
As a result, my soft numeric keypad won't display.
What the heck do I do? I've changed the styles in the Android Studio 1.1.0 dropdown in design mode but no matter what I choose I get the rendering problem and no keypad. I had colors set to Holo this and that because I liked the shades and I had Holo as the theme from the dropdown. I also have in AndroidManifest.xml this:
android:theme ="#style/AppTheme"
But when it was working, I had commented that out to get nice black background. Either way, no keypad.
All I have in styles.xml is this:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.ThemeOverlay.AppCompat">
<!-- Customize your theme here. -->
</style>
</resources>
I exited and re-entered AS. No keypad; same problem.
I'll post all xml and activity java code if need be. This is insane.
Looks to me like there's a problem in APIs 17 & 18 with the definition of Widget.Holo.ActionMode. I added the following to my styles.xml file:
<!-- Put this here to fix rendering error in API 17-18 -->
<style name="Widget.Holo.ActionMode" parent="#android:style/Widget.Holo.ActionMode">
<item name="titleTextStyle">#android:style/TextAppearance.Holo.Widget.ActionMode.Title</item>
<item name="subtitleTextStyle">#android:style/TextAppearance.Holo.Widget.ActionMode.Subtitle</item>
</style>
This may happen on APIs below 17, haven't tested. It was fixed in 19.
Background
My app has the ability to search for items (which are other apps) using the SearchView on the ActionBar.
The app uses the support library of Google, and it works well on all versions of Android from API 9 .
The problem
On Lollipop, when I click the search action item in order to start searching, I notice that the up/back button on the top-left corner gets to be white, which is bad for this case since the actionbar background is also quite white:
Weird thing is that it doesn't always occur, and I don't think it occurs on Android versions that aren't Lollipop (tested on multiple emulators and devices).
Another weird thing is that the navigation drawer icon seems ok, as well as the X icon inside the searchView.
Here's the XML of the toolbar I have:
<android.support.v7.widget.Toolbar
android:id="#+id/activity_app_list__toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
the "colorPrimary" is set to be : #ffEFEFEF .
Also, the theme's parent of the activity is "Theme.AppCompat.Light.NoActionBar" , as I've set the toolbar to be the actionBar.
The question
How can I fix this issue?
What is the cause for this issue? How come it works fine on other Android versions?
It seems like a known issue: https://code.google.com/p/android/issues/detail?id=78346 .
workaround is here: https://code.google.com/p/android/issues/detail?id=78346#c5 , meaning:
values-21/themes.xml:
<style name="MyTheme" parent="Theme.AppCompat">
<item name="homeAsUpIndicator">#drawable/abc_ic_ab_back_mtrl_am_alpha</item>
</style>
That's it. Hope it gets fixed later.
In order to customize it, I assume I can use it, and also choose the color using "colorControlNormal"
I'd guess the "app:collapseIcon" attribute is what you were looking for?
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbarHeight"
app:collapseIcon="#drawable/collapseBackIcon" />
How can I fix this issue?
I created a utility class for this (and other) problems. Get it here:
https://gist.github.com/consp1racy/96958a1dedf5a99d4ca5
Part 1: Call the following method in your Activity.onCreate(Bundle):
ToolbarUtils.fixToolbar(mToolbar);
Part 2: The code uses value android:colorControlNormal from the Toolbar "theme" you specified in the layout. If you use support library and defined only colorControlNormal you need to add the following line after it:
<item name="android:colorControlNormal" tools:ignore="NewApi">?attr/colorControlNormal</item>
What is the cause of this issue?
After a lot of thought and experiments it seems that the arrow uses the original bitmap, which is white, without any coloring, which is wrong.
Note: The menu overflow icon also reads the android:colorControlNormal so now it will display correct color as well.
EDIT: Prerequisites:
Your Toolbar should have attributes similar to the following
<!-- custom toolbar theme -->
<item name="theme">#style/ThemeOverlay.MyApp.ActionBar</item>
<!-- light popup menu theme, change this if you need to -->
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
<!-- app bar background color -->
<item name="android:background">#color/material_deep_orange_500</item>
Then the toolbar theme should look something like this
<!-- example uses dark app bar template, feel free to change it to light if you need to -->
<style name="ThemeOverlay.MyApp.ActionBar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<!-- this line defines title text color -->
<item name="android:textColorPrimary">#color/material_white_100</item>
<!-- this line defines subtitle text color -->
<item name="android:textColorSecondary">#color/material_white_70</item>
<!-- this line defines up/hamburger/overflow icons color -->
<item name="colorControlNormal">#color/material_black_54</item>
<!-- this line is necessary for proper coloring on lollipop - do not delete it -->
<item name="android:colorControlNormal" tools:ignore="NewApi">?attr/colorControlNormal</item>
</style>
In my AndroidManifest file i do not declare a theme.
The result is:
black background and ABS with blue background, also states of list item's is blue.
thats fine.
now i want to make to set the indeterminateProgressStyle to Widget.ProgressBar.Small
Therefore i have to declare my own style like this:
<style name="Custom" parent="??">
<item name="android:actionBarStyle">#style/ActionBarIPS</item>
</style>
what should i enter in the parent parameter?
i want all style behaviors like before (black background with blue ABS and blue list item states etc as it is defined when i dont declare a theme attribute in AndroidManifest.
EDIT:
i also need to know this parent's value:
<style name="ActionBarIPS" parent="ABS with blue background">
<item name="android:indeterminateProgressStyle">#style/IndeterminateProgress</item>
</style>
the version without a style in manifest:
the version with custom style and parent=Theme.Sherlock
i want the first version with indeterminate spinner set to "small"
It's depend to your current style, It can be Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.ForceOverflow and etc, e.g:
<style name="Custom" parent="Theme.Sherlock or Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/ActionBarIPS</item>
<item name="android:indeterminateProgressStyle">#style/IndeterminateProgress</item>
</style>
Note: You must declare this style in style.xml in your values directory.
Edited:
You got blue ActionBar without using ABS because you're using Samsung TouchWiz default UI.
If you install your APK in non-samsung devices you won't see this blue action bar, But If you are forced to have blue actionbar then put the following image in your drawable directory and set it as your actionbar background through:
getSupportActionBar().setBackgroundDrawable(getResources()
.getDrawable(R.drawable.TouchWiz_ActionBar_Bg));
Try to use "Theme.Sherlock" as a parent. Also I suggest to add:
<item name="actionBarStyle">#style/ActionBarIPS</item>