I'm applying this this to my base activity in manifest file.
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">#color/darkRed</item>
</style>
But my status bar in base activity appears to be in blue colour. What am I suppose to do.
This is because in style.xml file you have not use colorPrimaryDark to change status bar color.
So if you are using material design to create your application then please refer this guidelines as shown below:
https://material.google.com/
https://developer.android.com/training/material/index.html
http://www.androidhive.info/2015/04/android-getting-started-with-material-design/
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<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:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">#color/darkRed</item>
</style>
Try this.
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">#color/colorPrimary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#color/colorAccent</item>
</style>
Related
This is style i have used for material Calendar separately, everything is perfect except selected date circle
<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:windowBackground">#color/colorAppBackground</item>
<item name="android:actionMenuTextAppearance">#style/RobotoMenuText</item>
<item name="titleTextAppearance">#style/RobotoMenuText</item>
<item name="android:windowIsTranslucent">true</item>
<item name="titleTextStyle">#style/RobotoMenuText</item>
<item name="colorSurface">#color/colorAppGreen</item>
<item name="materialCalendarTheme">#style/CalenderTheme</item>
<item name="materialCalendarFullscreenTheme">#style/ThemeOverlay.MaterialComponents.MaterialCalendar.Fullscreen</item>
<item name="materialCalendarStyle">#style/Widget.MaterialComponents.MaterialCalendar</item>
</style>
<style name="CalenderTheme" parent="Theme.MaterialComponents.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:windowBackground">#color/colorAppBackground</item>
</style>
You have to switch from the Theme.AppCompat to a Theme.MaterialComponents or a Bridge Theme.
Use:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge">
<!-- ...... -->
<item name="materialCalendarStyle">#style/Widget.MaterialComponents.MaterialCalendar</item>
<item name="materialCalendarFullscreenTheme">#style/ThemeOverlay.MaterialComponents.MaterialCalendar.Fullscreen</item>
<item name="materialCalendarTheme">#style/ThemeOverlay.MaterialComponents.MaterialCalendar</item>
</style>
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>
I don't know if is related with git but after committing my project using git, every Activity's background color is changed even when I create a new Activity.
Why?
My style file
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.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="drawerArrowStyle">#style/MyDrawerArrowToggle</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="MyDrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">#color/toolbar_text_color</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorControlNormal">#color/textColor</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"></style>
</resources>
<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="drawerArrowStyle">#style/MyDrawerArrowToggle</item>
</style>
I changed "Theme.AppCompat.NoActionBar" to "Theme.AppCompat.Light.NoActionBar".
It is worked.Thanks everyone....
Here is the mistake you are using dark theme
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorControlNormal">#color/textColor</item>
i have developed an android app with search view on action bar
but the suggestion drop down menu items are dark.
is there a way i can turn the drop down menu to light ?
this is my style.xml file
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<!--<item name="android:dropDownListViewStyle">#android:style/Widget.DeviceDefault.Light.ListView.DropDown</item>-->
<item name="colorAccent">#color/colorAccent</item>
<item name="android:actionBarWidgetTheme">#style/Widget.AppCompat.Light.ActionBar</item>
<item name="android:popupMenuStyle">#android:style/Widget.Holo.Light.PopupMenu</item>
<!--<item name="android:dropDownListViewStyle">#android:style/Theme.Light</item>-->
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.ButtonBase" parent="Widget.AppCompat.Button.Colored">
<item name="android:paddingTop">12dip</item>
<item name="android:paddingBottom">12dip</item>
<item name="android:textSize">16.9sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="AppTheme.ButtonPrimary" parent="AppTheme.ButtonBase">
<item name="colorButtonNormal">#color/buttonPrimary</item>
<item name="android:textColor">#color/textLight</item>
</style>
<style name="MineCustomTabText" parent="TextAppearance.Design.Tab">
<item name="android:textSize">18sp</item>
</style>
<style name="AppTheme.ButtonSecondary" parent="AppTheme.ButtonBase">
<item name="android:textColor">#color/textLight</item>
</style>
Just comment out your style code. for below attribute in your code.
android:dropDownListViewStyle
Now build and run your app again.
It will help you.
I am encountering a very strange error in my application. It shows the text of a button, but not the button itself. Here is a screenshot:
I then checked the Theme Editor to see what might happen, and what I get in there looks like this:
The editor seems to be unable to render Material design correctly, no matter if it is dark or light. When I switch it to Holo for example, everything works fine.
My AndroidStudio is up to date, I have no idea what is going on, but I will provide my styles.xml files here as well:
v21\styles.xml
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
<item name="preferenceStyle">#style/PreferenceThemeOverlay.v14.Material</item>
</style>
<style name="MyActionBarTheme" parent="android:Widget.Material.Light.ActionBar">
<item name="android:background">#color/colorAccent</item>
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Material.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorPrimary</item>
</style>
<style name="AppTheme" parent="android:Theme.Material.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:colorBackground">#color/background_material_light</item>
<item name="android:colorPrimary">#color/primary_material_light</item>
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
<item name="preferenceStyle">#style/PreferenceThemeOverlay.v14.Material</item>
</style>
</resources>
styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.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:colorBackground">#color/background_material_light</item>
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
<item name="preferenceStyle">#style/PreferenceThemeOverlay.v14.Material</item>
</style>
<style name="MyActionBarTheme" parent="Widget.AppCompat.ActionBar">
<item name="android:background">#color/colorAccent</item>
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/colorPrimary</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
<item name="preferenceStyle">#style/PreferenceThemeOverlay.v14.Material</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Ok, I finally found out what was causing the error: My main activity was extending AppCompatActivity (This was generated by Android Studio in an earlier stage). When I changed this to extend FragmentActivity, everything worked like a charm.
This solution solved both the button as well as the theme editor problem. I do not know why theme editor would not show the custom material design when my main application does not extend the correct class, but this small piece of code changed fixed all my issues.