1

I've created custom enter animation for a dialog:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="5000" />

Dialog should rotate around it's center... but it doesn't. It rotates around some other point. What's wrong here?

--- Edit: attached more code ---

Dialog creation:

Dialog dialog = new Dialog(SampleActivity.this, R.style.DialogStyle);
dialog.setContentView(R.layout.test_layout);
dialog.show();

styles.xml:

<style name="DialogStyle" parent="android:Theme.Dialog">
  <item name="android:windowAnimationStyle">@style/DialogAnimation</item>
</style>

<style name="DialogAnimation">
  <item name="android:windowEnterAnimation">@anim/dialog_enter</item>
</style>

test_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="270dip"
    android:layout_height="wrap_content">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Random text\nRandom text\nRandom text" />
</LinearLayout>
Sebastian Nowak
  • 5,607
  • 8
  • 67
  • 107

1 Answers1

0

This is a stab in the dark, but what I think is happening is that the animation code sees that the beginning and end position are the same, and therefore doesn't actually rotate (but having never done this, I'm not sure).

You could test this hypothesis by changing android:toDegrees to "180" to see if that works. If so, you can just do two 180 flips, one right after the other.

Other than that, we may need to see more code to understand the problem.

mtmurdock
  • 12,756
  • 21
  • 65
  • 108