Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7671607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:05:53+00:00 2026-05-31T16:05:53+00:00

I would like to try out different animation styles for a popup window using

  • 0

I would like to try out different animation styles for a popup window using setAnimationStyle(), but I am struggling to understand the documentation.

developer.android.com, says: “animation style to use when the popup appears and disappears. Set to -1 for the default animation, 0 for no animation, or a resource identifier for an explicit animation.”

It does not give any examples, or tell me what choices of resource are available. I suspect the best animation for my purposes will be sliding in from the right… does that exist as an option? Are these things I can select from a list or do I have to somehow create my own?

EDIT: My current code for making my popup window is something like this (simplified):

public void completed_dialog()
{
  runOnUiThread(new Runnable()
  {
    public void run()
    {

      View layout = inflater.inflate(R.layout.endofgame, null, false);

      Button b1 = (Button) layout.findViewById(R.id.pu_menu);
      Button b2 = (Button) layout.findViewById(R.id.pu_repeat);
      Button b3 = (Button) layout.findViewById(R.id.pu_next);

      b1.setBackgroundResource(R.drawable.custom_menu_but);
      b2.setBackgroundResource(R.drawable.custom_repeat_but);
      b3.setBackgroundResource(R.drawable.custom_next_but);

      b1.setOnClickListener(menu_button_click_listener);
      b2.setOnClickListener(repeat_button_click_listener);
      b3.setOnClickListener(next_button_click_listener);

      final PopupWindow pw = new PopupWindow(layout, canvas_width, 
                                                       canvas_width /2,  true);

      pw.setAnimationStyle(android.R.style.Animation_Dialog);
      pw.showAtLocation(game_frame_layout, Gravity.CENTER, 0, 0);
    }
  }
}

I have now put the following in a file res/anim/test.xml :

<?xml version="1.0" encoding="utf-8"?>

    <set xmlns:android="http://schemas.android.com/apk/res/android">
            <scale
                    android:fromXScale="0.3" android:toXScale="1.0"
                    android:fromYScale="0.3" android:toYScale="1.0"
                    android:pivotX="0%" android:pivotY="0%"
                    android:duration="@android:integer/config_shortAnimTime"
            />
            <alpha
                    android:interpolator="@android:anim/decelerate_interpolator"
                    android:fromAlpha="0.0" android:toAlpha="1.0"
                    android:duration="@android:integer/config_shortAnimTime"
            />
    </set>

The original code with pw.setAnimationStyle(android.R.style.Animation_Dialog); worked fine, in as much as the dialog appeared with the standard animation – but if I swapped that line with pw.setAnimationStyle(R.anim.test); there is no animation. I have no idea why.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:05:54+00:00Added an answer on May 31, 2026 at 4:05 pm

    this is working example of setAnimationStyle() on my end:

    res/anim/in.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator">
        <translate 
            android:fromYDelta="854" 
            android:toYDelta="0"
            android:duration="1000"/>
    </set>
    

    res/anim/out.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">  
        <translate android:interpolator="@android:anim/decelerate_interpolator"
            android:fromYDelta="0"
            android:toYDelta="854" 
            android:duration="10000"
        />
    </set>
    

    layout/main.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/layout"
        >
        <Button
            android:id="@+id/btn_show"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:text="show"
            />
    </RelativeLayout >
    

    layout/popup.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:background="#cccccc" 
        > 
        <Button 
            android:id="@+id/btn_dismiss"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="dismiss"/>
    </LinearLayout>
    

    values/styles.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <style name="PopupAnimation" parent="android:Animation" mce_bogus="1">      
             <item name="android:windowEnterAnimation">@anim/in</item>  
            <item name="android:windowExitAnimation">@anim/out</item>  
        </style>  
    </resources>
    

    values/strings.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="hello">Hello World, MainActivity!</string>
        <string name="app_name">Popupwindow</string>
    </resources>
    

    MainActivity.java :

    public class MainActivity extends Activity {
        /** Called when the activity is first created. */
        boolean flag =false;
        PopupWindow popupWindow;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            init();
        }
        public void init() {
            Button btn_show = (Button) findViewById(R.id.btn_show);
            LayoutInflater inflater = LayoutInflater.from(this);
            View layout = inflater.inflate(R.layout.popup, null);
            popupWindow =new PopupWindow(layout, LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT);
            Button btn_dismiss = (Button) layout.findViewById(R.id.btn_dismiss);
            btn_dismiss.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    openMenu();
                }
            });
            btn_show.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    openMenu();
                }
            });
        }
    
        public void btn_showOnClicked() {
            openMenu();
        }
    
        public void btn_dismissOnClicked() {
            openMenu();
        }
    
        public void openMenu() {
            if (!flag) {
                popupWindow.setAnimationStyle(R.style.PopupAnimation);
                popupWindow.showAtLocation(findViewById(R.id.btn_show), Gravity.NO_GRAVITY, 0, 0);
                popupWindow.setFocusable(true);
                popupWindow.update();
                flag =true;
            } else {
                popupWindow.dismiss();
                popupWindow.setFocusable(false);
                flag =false;
            }
        }
    }
    

    and in your code just add your anim file to style as:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <style name="test" parent="android:Animation" mce_bogus="1">      
             <item name="android:windowEnterAnimation">@anim/test</item>  
        </style>  
    </resources>
    

    and in code:

    pw.setAnimationStyle(android.R.style.test);
    

    Thanks & Happy Coding!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to try out Capistrano to deploy a PHP application but can't
I would like to try programming genie , but I can't find neither source
I built a slideshow/decision-making game in Flash but would like to try to redo
I would try something like this but it isn't allowed. function GetDynamicModulesProperties() { var
I would like to try this code: public struct Direction { private int _azimuth;
I have an OS design project with some subprojects, I would like to try
I would like to to try Emacs, and want to give it the best
I would like to implement an B+ tree in Java and try to optimize
I'm starting to try and test my Doctrine objects with PHPUnit, and would like
I would like to find out if someone (and maybe someone on StackOverflow works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.