The error message is "Cannot resolve symbol '#style/AppTheme'"
Here is the 2nd problem.
You should create your own AppTheme in the values/styles.xml file, for example:
<!-- 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>
Related
i am trying to disable dark mode in my app and its working on android 10 or higher but its not working on android 9. Can anyone please help me out here. Thanks in advance.
In on create method i have done below,
in theme or theme(night), in both files i placed
<style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- <style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.Light.NoActionBar">-->
<!-- Primary brand color. -->
<item name="android:windowActivityTransitions">true</item>
<!-- <item name="android:windowEnterTransition">#transition/explode_old</item>-->
<!-- <item name="android:windowExitTransition">#transition/explode_old</item>-->
<item name="colorPrimary">#color/purple_500</item>
<item name="colorPrimaryVariant">#color/purple_700</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/teal_200</item>
<item name="colorSecondaryVariant">#color/teal_700</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">#color/white</item>
<item name="android:windowLightStatusBar">true</item>
<!-- Customize your theme here. -->
</style>
also write below line but not working with anroid 9
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
Change the parent attribute of your app style in themes.xml from
<style name="Theme.AppName" parent="Theme.MaterialComponents.DayNight.NoActionBar">
to
<style name="Theme.AppName" parent="Theme.MaterialComponents.Light.NoActionBar">
Is it Right As Josh and another way to see if You have the theme(night) then delete it
I am currently making a gallery app and I want to use the full screen for displaying my images. For this I would have to use the Notch area on my Oneplus 6T as well, which I cannot get to work. Ever source I've looked at said to use windowLayoutInDisplayCutoutMode which doesn't seem to work for me and the Notch area is still blacked out and unused by the app. I have totally run out of ideas of how to fix this and cannot find any more results on the internet.
App Theme:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Raspjannis" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/pastelBlue</item>
<item name="colorPrimaryVariant">#color/iconBlue</item>
<item name="colorOnPrimary">#color/black</item>
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
<item name="android:textColorSecondary">#color/iconBlue</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/iconBlue</item>
<item name="colorSecondaryVariant">#color/pastelBlue</item>
<item name="colorOnSecondary">#color/white</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimary</item>
<!-- Customize your theme here. -->
<!-- Backgrounds Theme -->
<item name="backgroundColor">#color/pastelBlue</item>
<item name="cardBackgroundColor">#color/white</item>
<item name="cardForegroundColor">#color/white</item>
<item name="editTextBackground">#color/bright</item>
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">
shortEdges <!-- default, shortEdges, or never -->
</item>
</style>
<style name="Theme.Raspjannis.NoActionBar.splashScreenTheme" parent="Theme.Raspjannis.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
</style>
<style name="ActionBarTheme">
</style>
<style name="Theme.Raspjannis.NoActionBar" parent="Theme.Raspjannis">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.Raspjannis.NoStatusBar">
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">
shortEdges <!-- default, shortEdges, or never -->
</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="Theme.Raspjannis.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.Raspjannis.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<!-- This style is where you define the tint color of your overflow menu button -->
<style name="actionOverflowButtonStyle" parent="#style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">#color/dark</item>
</style>
<style name="menuItem" parent="Widget.AppCompat.TextView.SpinnerItem">
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
</style>
<style name="icons" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:itemBackground">#color/white</item>
<item name="android:textColor">#color/dark</item>
<item name="android:tint">#color/dark</item>
</style>
And here is the code that sets the theme and fullscreen:
public static void hideSystemUI(Activity activity) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
activity.setTheme(R.style.Theme_Raspjannis_NoStatusBar);
}
public static void showSystemUI(Activity activity) {
activity.setTheme(R.style.Theme_Raspjannis);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
When I try to create a style as indicated by:
https://developers.google.com/cast/docs/android_sender_advanced#customize_cast_button like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#7788FF</item>
<item name="colorPrimaryDark">#7700FF</item>
<item name="mediaRouteTheme">#style/CustomMediaRouterTheme</item>
</style>
<style name="CustomMediaRouterTheme" parent="Theme.MediaRouter">
<item name="mediaRouteButtonStyle">#style/CustomMediaRouteButtonStyle</item>
</style>
<style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton">
<item name="buttonTint">#CCCC00</item>
</style>
I get the following error:
Error:error: style attribute 'attr/mediaRouteTheme (aka com.*:attr/mediaRouteTheme)' not found.
What am I doing wrong?
I Used this dependency in build.gradle compile 'com.android.support:mediarouter-v7:25.3.1'
and in style.xml
<!-- Base application theme. -->
<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="mediaRouteTheme">#style/CustomMediaRouterTheme</item>
</style>
<style name="CustomMediaRouterTheme" parent="Theme.MediaRouter">
<item name="mediaRouteButtonStyle">#style/CustomMediaRouteButtonStyle</item>
</style>
<style name="CustomMediaRouteButtonStyle" parent="Widget.MediaRouter.Light.MediaRouteButton">
<item name="buttonTint">#CCCC00</item>
</style>
its working fine, not getting any error. try with this gradle dependency.
From support library v26.0.0, the "buttonTint" is changed to "mediaRouteButtonTint".
Replacing "mediaRouteButtonTint" with "buttonTint" would fix the issue.
Found the following solution from: https://smartapps.egeniq.com/style-mediaroutebutton-change-chromecast-icon-color-ecc98d72abe4
Context castContext = new ContextThemeWrapper(this.getBaseContext(), android.support.v7.mediarouter.R.style.Theme_MediaRouter);
Drawable drawable = null;
TypedArray a = castContext.obtainStyledAttributes(null,
android.support.v7.mediarouter.R.styleable.MediaRouteButton, android.support.v7.mediarouter.R.attr.mediaRouteButtonStyle, 0);
drawable = a.getDrawable(
android.support.v7.mediarouter.R.styleable.MediaRouteButton_externalRouteEnabledDrawable);
a.recycle();
MediaRouteButton mrb = (MediaRouteButton)findViewById(R.id.media_route_menu_item);
DrawableCompat.setTint(drawable, 0xFFCCCCCC);
mrb.setRemoteIndicatorDrawable(drawable);
CastButtonFactory.setUpMediaRouteButton(this, mrb);
Here's my styles.xml file:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:actionMenuTextColor">#style/TitleBarTextColor</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#060EBB</item>
</style>
<style name="MyActionBarTitleText"
parent="#style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#00B300</item>
</style>
<style name="TitleBarTextColor" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#00B300</item>
</style>
</resources>
Here's my manifest file:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyCustomTheme" >
The background of the ActionBar is changing color the way I want it to, but the text itself isn't. What am I doing wrong? Oh, and some explanation of the way styles.xml works within Android would be nice too. It seems to be very confusing.
change your
code from
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#060EBB</item>
</style>
to
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#060EBB</item>
<item name="android:titleTextStyle">#style/TitleColor</item>
</style>
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#00B300</item>
</style>
Style.xml
style.xml file states what are the styles you want to use in your app, basically it inherits android default style
as you can see in every style tag which ever property you want to set you give it a name
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
and say what property of parent style you want to override, Parent style is the theme which you selected as default theme when you created app.
I'm using in my style.xml as main app theme
<style name="AppTheme" parent="Theme.AppCompat.Light">
And all AlertDialogs using same white/blue colors. But i have Activities which working as Dialog parent="android:Theme.Dialog" and this box use dark theme. How could I change it to AppCompat.Light theme?
I tryed Theme.AppCompat.Light.Dialog but as you know it doesn't working well.
Thanks.
You can use this theme:
<style name="AppTheme" parent="android:Theme.DeviceDefault.Light.Dialog">
Or this:
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="MyAppCompatDialogTheme" parent="AppBaseTheme">
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
source last code