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.
Related
I'm not a developer. I have a problem while editing a google search widget. Google app crashes with this log: https://del.dog/bihagetole
What should i do to fix that?
You must define the theme parent in your styles.xml file
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. This one does not have a action bar for example -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Before upgrading to android 3.1.I usually just change the theme to a theme. app compact. NoTitleBar but the new version of android studio is having errors recognizing it.I solved this problem by adding base to the beginning. But I can seem to find any answer regarding a style theme that supports removing the custom bar.
In your res/values/styles.xml you have this similar block of code.
Ensure that you use Theme.AppCompat.Light.NoActionBar as parent of your theme
<!-- 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>
</style>
Add this style in style file . where other styles are mentioned .
<!-- Base application theme. -->
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimaryDark</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorPrimaryDark</item>
<item name="android:statusBarColor">#color/lightgreycolor</item>
</style>
In my case, i had to change parent theme in res/values/themes.xml
I am trying to understand the theming and styling system of Android and basically attempt to do the simplest thing - change the default color of TextView texts.
According to the source code of TextView the default style would be:
<item name="textViewStyle">#style/Widget.TextView</item>
Looking at this style I discover the following:
<style name="Widget.TextView">
<item name="textAppearance">?attr/textAppearanceSmall</item>
....
</style>
It seems that the default textAppearance is set to textAppearanceSmall (from the theme).
I look into themes.xml for the referenced textAppearanceSmall and find this:
<item name="textAppearanceSmall">#style/TextAppearance.Small</item>
Aha - it references this TextAppearance.Small:
<style name="TextAppearance.Small">
<item name="textSize">14sp</item>
<item name="textColor">?textColorSecondary</item>
</style>
Ok, we are getting somewhere - maybe? By default TextView uses the color "textColorSecondary".
First immediate question: Why is it references so weirdly? (questionmark but not like '?attr/textColorSecondary')?
I go back to the themes.xml file and discover this:
<item name="textColorSecondary">#color/secondary_text_dark</item>
At this point I am pretty sure that I have to override textColorSecondary in my custom AppTheme like so:
<!-- 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>
<item name="android:textColorPrimary">#00CC00</item>
</style>
This does of course not work... the question is - why?
BTW: All the files I am looking at (theme.xml & styles.xml) reside in my Android SDK directory:
C:\AndroidSDK\platforms\android-26\data\res\values
Try this:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:textColor">#color/white</item>
</style>
Beginner coder here.
I am using PreferenceFragmentCompat to make a preference fragment that I can use with getSupportFragmentManager().
https://plus.google.com/+AndroidDevelopers/posts/9kZ3SsXdT2T
I am following the directions there, except I'm not sure how to set the preferenceTheme. My app crashes when I click on the settings menu with this exception is thrown
IllegalStateException: Must specify preferenceTheme in theme.
Where do I set the theme?
In values/styles.xml you have to add:
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
use this:
<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="preferenceTheme">#style/PreferenceThemeOverlay</item>
</style>
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.