Dianne Hackborn wrote:
> That comment is out of data, the window manager can use styles from
> applications.
>
> Sorry about the lack of documentation.  For now you'll need to look at the
> source resources to see how they are constructed and do the same thing.
> Note that there are two main types of window animations: single-window, and
> application.  The toast is a single-window.  Many others are application
> animations which use different entries in the style resource.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support.  All such questions should be posted on public
> forums, where I and others can see and answer them.

hi Dianne,

i tried to create own style as you suggested.

so i copied android std (and working) Toast animations to my res/anim
folder
(i had to add "android:" in front of anim/decelerate_interpolator
in "android:iterpolator" attribute):

res/anim/toast_enter.xml
-----------------------
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android";
        android:interpolator="@android:anim/decelerate_interpolator"
        android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="400" />
-----------------------

res/anim/toast_exit.xml
-----------------------
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android";
        android:interpolator="@android:anim/decelerate_interpolator"
        android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="400"
/>
-----------------------

and added the following style (i didn't add Animation style as its
only namespace,
though i also tried with Animation.Toast):

res/values/styles.xml
-----------------------
    ...
    <style name="Toast">
        <item name="android:windowEnterAnimation">@anim/toast_enter</
item>
        <item name="android:windowExitAnimation">@anim/toast_exit</
item>
    </style>
    ...
-----------------------

and setup popup's animation:

popup.setAnimationStyle(R.style.Toast)

and my PopupWindow animation is not working (when using:

popup.setAnimationStyle(android.R.style.Animation_Toast)

everything is OK), but i got on the console:

-----------------------
[ 03-03 10:51:30.765    51:0x33 W/ResourceType ]
Invalid package identifier when getting bag for resource number
0x7f0a000a
-----------------------

this log comes from kibs/utils/ResourceTypes.cpp, method
ResTable::getBagLocked

it seems that ResTable::getResourcePackageIndex returns value < 0
-----------------------
    const ssize_t p = getResourcePackageIndex(resID);
    const int t = Res_GETTYPE(resID);
    const int e = Res_GETENTRY(resID);

    if (p < 0) {
        LOGW("Invalid package identifier when getting bag for resource
number 0x%08x", resID);
        return BAD_INDEX;
    }
-----------------------

so tried to verify if 0x7f0a000a really exists:

aapt d resources bin/AndroidMiscWidgets.apk | grep 0x7f0a000a
-----------------------
      spec resource 0x7f0a000a org.miscwidgets:style/Toast:
flags=0x00000000
        resource 0x7f0a000a org.miscwidgets:style/Toast: <bag>
-----------------------

also added some test code for getting more info from Resources about
R.style.Toast

Resources r = getResources();
int id = r.getIdentifier("org.miscwidgets:style/Toast", null, null);
Log.d("test", "id == R.style/Toast " + (id == R.style.Toast));   //
result true

String hexId = Integer.toHexString(id);
Log.d("test", "id for org.miscwidgets:style/Toast " + hexId);    //
result 7f0a000a

String name = r.getResourceEntryName(R.style.Toast);
Log.d("test", "entry name for " + hexId + ": " + name);           //
result Toast

name = r.getResourceName(R.style.Toast);
Log.d("test", "name for " + hexId + ": " + name);                   //
result org.miscwidgets:style/Toast

name = r.getResourcePackageName(R.style.Toast);
Log.d("test", "package for " + hexId + ": " + name);               //
result org.miscwidgets

name = r.getResourceTypeName(R.style.Toast);
Log.d("test", "type for " + hexId + ": " +
name);                     // result style


this is logcat output:

-----------------------
[ 03-03 10:51:30.085  1712:0x6b0 D/test     ]
id == R.style/Toast true

[ 03-03 10:51:30.107  1712:0x6b0 D/test     ]
id for org.miscwidgets:style/Toast 7f0a000a

[ 03-03 10:51:30.107  1712:0x6b0 D/test     ]
entry name for 7f0a000a: Toast

[ 03-03 10:51:30.107  1712:0x6b0 D/test     ]
name for 7f0a000a: org.miscwidgets:style/Toast

[ 03-03 10:51:30.107  1712:0x6b0 D/test     ]
package for 7f0a000a: org.miscwidgets

[ 03-03 10:51:30.107  1712:0x6b0 D/test     ]
type for 7f0a000a: style

[ 03-03 10:51:30.765    51:0x33 W/ResourceType ]
Invalid package identifier when getting bag for resource number
0x7f0a000a
-----------------------

so it seems that resId 0x7f0a000a has valid package, but
getResourcePackageIndex(0x7f0a000a) says something else

is it a bug (application bag resources were not tested)
or i need to add something to my style definition ?

thanks
skink

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to