Android windowEnterAnimation attribute does not exist - android

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)

Related

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

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"

Why can't I use this attribute in my android theme?

To start with some context, I'm trying to style the background color of a SearchView widget. A really insightful so answer to this problem has already been posted, and I learned immensely from it.
There is one gap in my understanding though, and I'm hoping someone can explain it to me. When I create a theme, such as the following:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyCustomTheme" parent="android:Theme">
<item name="android:searchViewTextField">#android:color/white</item>
</style>
</resources>
Eclipse compiles with an error saying it doesn't know about the attribute:
error: Error: No resource found that matches the given name: attr 'android:searchViewTextField'.
However, if I re-declare the attribute:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<declare-styleable name="CustomSearchView">
<attr name="android:searchViewTextField" format="reference" />
</declare-styleable>
</resources>
Eclipse responds with an error saying:
error: Attribute "android:searchViewTextField" has already been defined
Eclipse seems to be aware of the attribute, but conveniently forgets about that attribute when I want to use it. (I wonder if there is some context switching going on in the background)
At any rate, if I delete the problem code then I can see my custom theme inheriting searchViewTextField from its parent. I just don't understand why I can't supplant it with my own.
(The other answer mentions android.R.stylable, but that file is obsolete in api 16)
Thanks in advance.
Relevant Android sources:
themes.xml, attrs.xml, and search_view.xml (sorry, two link limitation).
The answer in the SO answer you linked explicitly says that you cannot specify searchViewTextField in your own theme because it is not a stylable resource. You need to modify it's value in code as per the other answer.
The question was, why can't I use the theme attribute "android:searchViewTextField"?
Out of suspicion that the compiled Android.jar file was not in tune with the published Android source, I ripped open the jar and started decompiling (a first for me). After poking around, it does appear that someone went into R$style.class with a machete and hacked out a massive chunk of the resources. As far as I can ascertain, it must have been done deliberately and perhaps even manually.
This kind of compiled source modification is not without precedent in other similar frameworks, but it sure as hell is confusing to anyone trying to debug the framework.
Ironically, auto-generated R files all have a header that says,
/* AUTO-GENERATED FILE. DO NOT MODIFY.
Kinda pointless when you make it routine procedure to modify the files.

?android:attr/selectableItemBackground

when writing my android app i used
android:background="?android:attr/selectableItemBackground"
I tried looking for attr.xml file that would be containing the source but i could not find it. Any ideas please on where i can find it. I found one attr.xml in
C:\Program Files (x86)\Android\android-sdk\platforms\android-13\data\res\values
but it did not have the attribute mentioned above. Can anyone lead me where I can find the xml resource with the attribute above?
I'm not that experienced with Android, but I think you can find what you're looking for in "data\res\values\themes.xml".
If you search in that file for "selectableItemBackground", you should find the following:
<style name="Theme">
...
<item name="selectableItemBackground">#android:drawable/item_background</item>
...
</style>
You'll also find respective entries for Theme.Holo.Light and Theme.Holo. The *"item_background"*, *"item_background_holo_light"*, and *"item_background_holo_dark"* drawables would be located in the "data\res\drawable" folder.
Hope that helps!

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.

Style / themes not working

whenever I try to apply a VERY simple style in eclipse I get errors:
the style is as below (filename styles.xml in res/layout)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="commonStyle">
<item name="android:background">#EEEEEE</item>
</style>
</resources>
Regardless of whether I try to apply this to a LinearLayout (using style="#style/commonStyle") or to an activity in my manifest file (using android:theme="#style/commonStyle") I ALWAYS get the error "No resource found that matches the given name...".
If I try to apply an Android theme to an activity (say Theme.Black) it works just fine.
If I remove any usage of my style, my R.java file is generated as normal with the following contents:
public static final int styles=0x7f030002; (in the generated layout class)
I have NO idea what is going on. It seems that NOONE is having the same troubles as me (Ive spent about 4 hours searching using google, and came up with not even a remotely close answer).
Ive tried restarting eclipse, clean building etc. etc. and nothing works what so ever...
So what am I missing?
Try moving your styles.xml file to res/values.
http://developer.android.com/guide/topics/resources/style-resource.html
Styles need to be stored in the res/values folder :)
http://developer.android.com/guide/topics/ui/themes.html (See Defining Styles)
The name of the XML file is arbitrary,
but it must use the .xml extension and
be saved in the res/values/ folder.
I haven't used styles in my code yet, however generally you need to use
android:
Does it work when you use this?:
<style android:name="commonStyle">
Please verify the you call the style in the correct manner :
for example this might compile but will not work :
style="mainButtonText"
this is the correct way to call style:
style="#style/mainButtonText"

Categories

Resources