No resource found that matches the given name '#android:style/Theme.MyStyle' - android

I'm new to android programming (developing on Android Studio 0.8.11) and I'm having issues applying a custom theme to an ActionBar.
My goal is to create a complete custom actionBar with different colours and resources. My min SDK is 16.
Here is the example theme definition in the /res/values/styles.xml:
<style name="Theme.MyStyle" parent="#android:style/Theme.Holo.Light.DarkActionBar" >
<item name="android:actionMenuTextColor">#00FF00</item>
</style>
I'm trying to applying this to all the app with the following line in the manifest xml:
<application> [...] android:theme="#android:style/Theme.MyStyle">
</application>
However when I try to lookout for "Theme.MyStyle" the auto-completion seems not to find it. In fact that part is reded out and the compiler says "No resource found that matches the given name '#android:style/Theme.MyStyle'" .
I'm just trying to figure out how to correct applying a theme, all the guides found even on android developer makes the theming easy but I can't find what's wrong!
Any tips? Thank you very much!

#android:style is for predefined android styles
Change this
android:theme="#android:style/Theme.MyStyle"
into
android:theme="#style/Theme.MyStyle"

Related

Android studio Dolphin Render ui issue

I updated my android studio to Dolphin. I have some ui issue:
1.Infinite cycle trying to resolve '?textAppearance': Render may not be accurate.
2.Failed to find '#android:attr/textAppearance' in current theme.
This happens for a reason: There may indeed be styles missing.
Theme.MaterialComponents.Bridge & Widget.MaterialComponents
For example, when applying android:theme in XML:
android:theme="#style/AppTheme.FloatingActionButton"
But the referenced material style does not define any #android:attr/textAppearance:
<style name="AppTheme.FloatingActionButton" parent="Widget.MaterialComponents.FloatingActionButton">
<item name="android:textAppearance">#style/TextAppearance.AppCompat</item>
</style>
The style attribute might be missing somewhere else, than where the render error occurs.
When FragmentContainerView won't render, see app:startDestination and its tools:layout.
Searching for string android:theme in directory res/layout should turn up all the references.
I changed it compileSdkVersion 33 from 32 it works but neomorphism attributes are missing now.

What is a theme and how do I know if I have the "correct" one?

In my current project, when I select the Design tab in Android Studio 2.2.2 for a particular layout I get an error that says
Missing styles. Is the correct theme chosen for this layout?
and it goes on to say
Failed to find style 'textEditSuggestionItemLayout' in current theme
(42 similar errors not shown)
But, the actual layout renders OK in the Designer and at runtime.
There are lots of other S.O. posts on this, such as here and here and most of the answers seem to involve clearing the caches and restarting Android Studio, or selecting a different theme from the dropdown. I I have tried the first one but it didn't help. I haven't tried the second one yet because I don't really understand what a theme is.
Questions:
The error implies that there's an error in the theme itself. What
is that? Is the theme file part of my project, i.e., is it one
that I should be creating, editing, and that gets built and shipped
as part of my APK or is it only used in the developer IDE?
If I select a different theme from the dropdown how do I know what the
"correct" one is?
Since my project builds and runs OK as is, can I just ignore these
errors? In other words are these errors in my code or just a
problem with the development environment?
Edit: Some additional information after responding to comments, below:
The only place the string 'theme' is used in my manifest is
android:theme="#style/Theme.FullScreen"
... and FullScreen is the theme specified in the dropdown.
I did a search in my project for the string "textEditSuggestionItemLayout" and Android Studio found no occurrences of it.
If you've recently updated AS or any of its components, then try to 'Invalidate caches & restart'.
Else, try choosing AppTheme from the Design tab or change it to AppTheme from the default one. Choose the one that conforms to your parent app theme in your styles.xml.
The cause of the error could be anything from malfunctioning IDE to selecting a theme not mentioned in your styles.xml (most likely).
You could do a project-wide search for textEditSuggestionItemlayout, or the other styles that it claims to miss.
These are either in your own res/values/styles.xml and/or res/values/themes.xml files, or they are provided within the SDK, which is why you see some suggestions to uncheck 'Automatically Pick Best' and pick a version you have installed. In some cases, the latest API version's rendering tools don't work.
As an example, if you have your style set at Theme.Holo, but you are using the AppCompatActivity, you'll get a rendering error that you must use a Theme.AppCompat (or descendant). These themes are changeable from the dropdown of the design editor.
You can see what themes/styles are applied to your Activities within the AndroidManifest.xml.
res/values/styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/PrimaryColor</item>
<item name="colorPrimaryDark">#color/PrimaryDarkColor</item>
<!-- Customize your theme here. -->
</style>
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
Note: android:theme= and #style/
If you are still missing themes, then you may be missing some dependency, such as
compile 'com.android.support:design:<your_version_here>'
If your code runs fine, then sure, ignore it, but I think getting the layout designer working again shouldn't be ignored.

Changing Theme in Android Studio

I just noticed that the default theme when I am creating an android application in AS is Theme.AppCompat.Light.DarkActionBar which, for me, is very plain.
My question is how to use Holo Light Theme?
Because when I tried in giving me an error underlining the statement.
Can someone help me?
If you could show us what you're doing in your styles.xml file that isn't working it would be very helpful.
Otherwise, I think you're looking for something along the lines of <style name="AppTheme" parent="android:Theme.Holo.Light">. The key is that this is an android provided theme and is found using android:Theme

Android windowEnterAnimation attribute does not exist

I've been trying to follow this answer for adding an animation to a dialog box. However I'm getting an error on the first style addition.
I've added the following to res/values/styles.xml (not completely sure if this is correct)
<style name="DialogAnimation">
<item name="android:windowEnterAnimation">#anim/slide_down_dialog.xml</item>
<item name="android:windowExitAnimation">#anim/slide_out_up</item>
</style>
The first item, android:windowEnterAnimation, does not seem to exist when I tab complete android:. This also applies to android:windowExitAnimation. The error I receive in the XML file is:
error: Error: No resource found that matches the given name (at 'android:windowEnterAnimation' with value '#anim/slide_down_dialog.xml').
All the questions I've found regarding animation like this uses windowEnter/ExitAnimation. I looked at the android docs and it supposedly has this attribute, but I cannot for the life of me get it to appear.
Thanks in advance for any help/advice. If this is a duplicate please point me in the right direction, I couldn't find any related questions.
you sholud put # letter before android and remove the .xml like:
<item name="#android:windowEnterAnimation">#anim/slide_down_dialog</item>
I think it is:
remove (.xml) to be like (#anim/slide_down_dialog)

Android - Missing Parent Theme?

I'm attempting to style the ActionBar, following this blog post:
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
With this source code:
svn checkout http://styled-action-bar.googlecode.com/svn/trunk/ styled-action-bar-read-only
However, I'm getting issues in /res/values/styles.xml.
This:
<!-- style for the tabs -->
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBarView_TabView">
<item name="android:background">#drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
Is erroring with:
Error retrieving parent for item: No resource found that matches the given name 'android:style/Widget.Holo.Light.ActionBarView_TabView'.
However, using the following answer, and digging through the source for Android, I can see that the theme does indeed exist:
https://stackoverflow.com/a/7149389/420001
The only thing that I changed in the project was moving it from android-11 to android-14, and then running an "Android" > "Fix Project Properties" in Eclipse. I do note that the repo linked to in that answer, that lists the style, is on branch master, so I can't see why the theme would be unfound.
Just for tests, I put that chunk of code in my working android-14 targeting app, minus the background drawable, and it throws the same error.
According to the links in https://stackoverflow.com/a/7837756/1003511 there is a Widget_Holo_Light_ActionBar_TabView but not a Widget_Holo_Light_ActionBarView_TabView. It's possible the resource has been renamed since that tutorial was written. It says the version without the extra "view" has been included since API level 13 - if the tutorial was originally written on 11 it's possible it was renamed in 13, and since you are running 14 you can only see the renamed version. I'd try removing the extraneous "view" and see if the code runs.
You may be missing an '#' character when specifying that you want to look in the android styles:
You can also double check to see if the parent style is listed in the API documentation here:
http://developer.android.com/reference/android/R.style.html
It looks like you may have the name slightly wrong.

Categories

Resources