How can I apply animation(s) on a Popup Window

Put your problem here if it does not fit any of the other categories.

How can I apply animation(s) on a Popup Window

Postby nanye » Fri Apr 18, 2008 4:07 am

Hi,

I want to apply a slide-left animation effect on my newly pop-up window. I have looked through some codes, but still really confuse with how do animation. I do the following xml and code:

slide-left.xml:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4.  
  5.  
  6. <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
  7.  
  8.     <translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="150" />
  9.  
  10. </set>
  11.  
  12.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     @Override
  3.  
  4.     public void onCreate(Bundle icicle) {
  5.  
  6.         super.onCreate(icicle);
  7.  
  8.        
  9.  
  10.         requestWindowFeature(Window.FEATURE_NO_TITLE);
  11.  
  12.  
  13.  
  14.         setContentView(R.layout.main);
  15.  
  16.        
  17.  
  18.         Button b=(Button)findViewById(R.id.pnlbutton);
  19.  
  20.        
  21.  
  22.         b.setOnClickListener(new View.OnClickListener(){
  23.  
  24.                public void onClick(View v){
  25.  
  26.                    View contentView = getViewInflate().inflate(R.layout.popup,null,null);
  27.  
  28.                        PopupWindow mwindow = new PopupWindow(contentView, 320, 100);
  29.  
  30.  
  31.  
  32.                        popupAnimation = AnimationUtils.loadAnimation(Homescreen.this, R.anim.slide_left);
  33.  
  34.                        popupAnimation.setRepeatMode(Animation.NO_REPEAT);
  35.  
  36.                        
  37.  
  38.                        
  39.  
  40.                        mwindow.show(findViewById(R.id.mainwindow));
  41.  
  42.                        mwindow.setFocusable(true);
  43.  
  44.                        mwindow.update(0, 100,-1,-1);
  45.  
  46.                        mwindow.isShowing();
  47.  
  48.                        
  49.  
  50.                        contentView.startAnimation(popupAnimation);
  51.  
  52.                }
  53.  
  54.          });
  55.  
  56.     }      
  57.  
  58.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


The window pop-up but do a bottomup slide animation. I think that effect is default and not affected by my code.

Could any one can help me?

Best regards,
Nan YE
nanye
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri Apr 18, 2008 3:55 am

Top

Postby michael_g_hu » Fri Apr 18, 2008 11:37 am

you must use the method setAnimationStyle of popupwidow to change the animation directly
michael_g_hu
Developer
Developer
 
Posts: 35
Joined: Fri Mar 21, 2008 9:46 am

Postby nanye » Mon Apr 21, 2008 2:28 am

michael_g_hu wrote:you must use the method setAnimationStyle of popupwidow to change the animation directly

Thanks for your help, but I cannot find that method "setAnimationStyle" in Class PopupWindow :?
Would you like to give more details about this?
nanye
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri Apr 18, 2008 3:55 am

Postby michael_g_hu » Mon Apr 21, 2008 2:50 am

Maybe I use the newest SDK that not be released. So you can wait for the next release.
There is another way to handle the animation of a view is that you can you addView() to add a child view.
and set the child view's animation. However, you need to manage the focus yourself for all views in an activity
are in the same layout.
michael_g_hu
Developer
Developer
 
Posts: 35
Joined: Fri Mar 21, 2008 9:46 am

Postby nanye » Mon Apr 21, 2008 3:16 am

michael_g_hu wrote:Maybe I use the newest SDK that not be released. So you can wait for the next release.
There is another way to handle the animation of a view is that you can you addView() to add a child view.
and set the child view's animation. However, you need to manage the focus yourself for all views in an activity
are in the same layout.

Great, thanks for your qucik answer.
Looking forward the next release! I would like to use a simple and clear way to solve this problem rather than just a work around.

BTW, when will the next release be released :?: :D
nanye
Junior Developer
Junior Developer
 
Posts: 12
Joined: Fri Apr 18, 2008 3:55 am

how to add widget in popupwindow

Postby bins1984 » Mon Apr 21, 2008 10:10 am

HI........
i need a help on the topic of popup window........do u know how i can i access the widgets from the popup window..........if u can please give some sample codes.............



here i attached a file...its may help u for doing animation.............

thankfully...Bins..............
User avatar
bins1984
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Feb 08, 2008 8:20 am
Location: India

Top

Postby jmar777 » Tue Sep 16, 2008 5:40 pm

michael_g_hu wrote:you must use the method setAnimationStyle of popupwidow to change the animation directly

I realize that this thread has been dead for awhile, but if anyone has figured this out I would appreciate it if you could share. Even though setAnimationStyle() is in the current version of the SDK now, I can't determine what value to pass in. I don't believe there's any documentation on what the int relates to, and I can't find any sort of an "AnimationStyle" enum. I tried just passing in 0, 1, 2, etc. to see if there was any effect, but I can't seem to get any change out of it...
jmar777
Freshman
Freshman
 
Posts: 2
Joined: Fri Sep 12, 2008 8:36 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests