Style showing error in android - android

The following style shows error in eclipse
<style name="AppTheme" parent="android:style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="colorControlNormal">#color/primary</item>
<item name="colorControlActivated">#color/primary</item>
<item name="colorControlHighlight">#color/primary</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#color/white</item>
</style>
it shows a error like this
error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.AppCompat.Light.NoActionBar'.
while i searched, i get to know that it is the problem of the dependency. I tried a lot to solve it. But i still get the same error .
If i change the theme there is no error, but i need this particular style.
I tried the following theme
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
// Your style here
this is woking . but i need the above theme .

If your activity extends AppCompactActivity, your parent theme should be
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.NoActionBar" />
where as, if using ActionBarActivity, theme should be
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar" />
Make sure you have set up the dependencies in your project. This feature required appcompactv7.

Related

ScrimBackground from Theme.MaterialComponents is not Working

I'm trying to change the scrimBackground that show up when you opened a dialog. And I know that in the new MaterialComponents-Theme is an attribute for this case (scrimBackground). But it is currently not working for me.
On the material.io website that background is also descriped as the scrimBackground and it looks like that it is customizable from the Theme. Has anyone an idea what I'm doing wrong?
https://material.io/design/components/dialogs.html#theming
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="scrimBackground">#android:color/holo_blue_light</item>
<item name="dialogTheme">#drawable/window_scrim</item>
<item name="android:dialogTheme">#style/DialogTheme</item>
<item name="alertDialogTheme">#style/AlertDialogTheme</item>
<item name="android:alertDialogTheme">#style/AlertDialogTheme</item>
</style>
<style name="DialogTheme" parent="Theme.MaterialComponents.Dialog">
<item name="scrimBackground">#drawable/window_scrim</item>
</style>
<style name="AlertDialogTheme" parent="Theme.MaterialComponents.Dialog.Alert">
<item name="scrimBackground">#drawable/window_scrim</item>
</style>
The Material code does not appear to use this attribute even though it is defined. This issue tracks this problem. In the meantime, you may be able to change this without a Material Theme using the advise in Changing default Android fade/scrim color when calling a Dialog.

Failed to find style ... in current theme

I've faced a questionable error during my work with android studio.
Everytime I start studio and create a new project there is another render error
Failed to load AppCompat ActionBar with unknown error.
I do not clearly understand what does it mean, but it is easy to deal with it via replacing
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
but evertime I add new element to the layout, there is error
Failed to find style ... in current theme
I have found a solution, that helped almost everybody except me. But changing theme now doesn't solve the problem.
If anybody know how to deal with it please help.
You can copy the style name floatingactionbuttonstyle and included it in your apptheme.
Add this line
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
And finally theme look like this
<!-- 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="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
</style>
Just add the style name when error occured in layout editor & add the responding styles.
Here some other few elements am added in styles for others.
<!-- 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="chipStyle">#style/Base.Widget.MaterialComponents.Chip</item>
<item name="chipGroupStyle">#style/Widget.MaterialComponents.ChipGroup</item>
<item name="bottomNavigationStyle">#style/Widget.Design.BottomNavigationView</item>
<item name="coordinatorLayoutStyle">#style/Widget.Support.CoordinatorLayout</item>
<item name="bottomAppBarStyle">#style/Widget.MaterialComponents.BottomAppBar</item>
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
</style>
You can add default style with style name. Then you resolve this error.
In your app gradle under dependencies use this:
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
if you heven't already.

Overriding ActionBarCompat overflow pop-up background?

I am using actionbarcompat for my android project and using #style/Theme.AppCompat.Light.DarkActionBar as my base Theme.The overflow menu in this action bar has a black background by default which I want to change to white color.I know this can be done overdding the popup widget with property popupBackground but its not working in my case.My styles file has following code:
<style name="MyTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionDropDownStyle">#style/MyActionBarDropDown</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
<item name="popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
But the above code is not running as its giving me Error: No resource found that matches the given name: attr 'popupBackground'.SomeOne please help me to correct above code.
Just remove ->
<item name="popupBackground">#drawable/menu_dropdown_panel_example</item>
Put it like this ->
<style name="PopupMenu" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>

Error: No resource found that matches the given name: attr 'abBackground'

I'm using ActionBarSherlock, and want to use a custom background for both the ActionBar and the content view below it. When I try this, the background fills the whole screen, including the actionbar:
<style name="MyTheme" parent="#style/Theme.Sherlock">
<item name="android:windowBackground">#drawable/background</item>
</style>
So, from this answer, I tried to add abBackground to the theme:
<style name="MyTheme" parent="#style/Theme.Sherlock">
<item name="android:windowBackground">#drawable/background</item>
<item name="abBackground">#drawable/bg_button_idle</item>
</style>
However, I get the error
Error: No resource found that matches the given name: attr 'abBackground'.
Why is this, and how can I fix it?
Here's how you can change the actionbar background:
<style name="MyTheme" parent="Theme.Sherlock">
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.Sherlock.ActionBar">
<item name="background">#drawable/your_custom_drawable</item>
<item name="android:background">#drawable/your_custom_drawable</item>
</style>
//there is no abBackground
<item name="abBackground">#drawable/bg_button_idle</item>
//try
<item name="android:background">#drawable/bg_button_idle</item>
if the project is a library module you shou check the Library module

Fully transparent ActionBarSherlock by using theme

I am using ActionBarSherlock 4.0.2.
I need a fully transparent action bar (without the neon color bottom divider). Hence, I have the following style:
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="windowActionBarOverlay">true</item>
<item name="icon">#drawable/ic_home</item>
<item name="titleTextStyle">#style/ActionBarCompatTitle</item>
<item name="android:windowFullscreen">true</item>
</style>
By using above code, I will still have the following effect.
In order to disable the background, I put the following code in SherlockFragmentActivity#onCreate. Then the problem gone.
getSupportActionBar().setBackgroundDrawable(null);
However, I would like to see the solution being implemented in styles.xml instead of Java code, as I have many other devices with different screen configuration. I modified the styles.xml to the following, without using the previously mentioned fix in the Java code.
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="windowActionBarOverlay">true</item>
<item name="icon">#drawable/ic_home</item>
<item name="titleTextStyle">#style/ActionBarCompatTitle</item>
<item name="android:windowFullscreen">true</item>
<item name="android:background">#drawable/transparent</item>
<item name="background">#drawable/transparent</item>
</style>
However, the neon divider still visible. It seems that my fix using android:background and background does not work. Am I missing something?
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="#style/Widget.Sherlock.ActionBar">
<item name="background">#android:color/transparent</item>
<item name="android:background">#android:color/transparent</item>
</style>

Categories

Resources