LoginSignup
8
8

More than 5 years have passed since last update.

AndroidのアニメーションでfillAfterが効かない場合

Posted at

fillAfterが効かなくてちょっと焦ったのでメモ

このxmlのアニメーションは「fillAfter=true」にしてるが効かない

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="400"
        android:fillAfter="true"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toYScale="0.5"
        android:toXScale="0.5"></scale>
</set>

fillAfterをsetタグの方に設定するとちゃんと効く

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true">
    <scale
        android:duration="400" 
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toYScale="0.5"
        android:toXScale="0.5"></scale>
</set>

またはsetを外してscaleだけにする

<?xml version="1.0" encoding="utf-8"?>
    <scale xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="400"
        android:fillAfter="true"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toYScale="0.5"
        android:toXScale="0.5">
</scale>

どうも親タグにfillAfterつけないといけないみたいですね…

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8