I set the attribute "android:clipChildren" of LinearLayout to "false" and call setKeepAnimations(false) too. But it seems these are not affective. The animation is clipped with the bound of LinearLayout and the image is not return to the original size.
So, could anyone can help me?
The main java code: AnimationTest.java
Using java Syntax Highlighting
- package com.opensource.view;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.animation.Animation;
- import android.view.animation.AnimationUtils;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- public class AnimationTest extends Activity {
- private Animation mAnim = null;
- private ImageView mImageView = null;
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.animation_test);
- mAnim = AnimationUtils.loadAnimation(this, R.anim.anim);
- mAnim.setRepeatMode(Animation.NO_REPEAT);
- mImageView = (ImageView) findViewById(R.id.image);
- Button btn = (Button) findViewById(R.id.btn_ani);
- btn.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- mImageView.startAnimation(mAnim);
- }
- });
- LinearLayout layout = (LinearLayout) findViewById(R.id.anim_layout);
- layout.setKeepAnimations(false);
- }
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
The main layout XML: animation_test.xml
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <Button
- android:id="@+id/btn_ani"
- android:layout_alignParentTop="true"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Click to start animation"/>
- <LinearLayout
- android:id="@+id/anim_layout"
- android:layout_below="@id/btn_ani"
- android:layout_alignParentBottom="false"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:clipChildren="false">
- <ImageView
- android:id="@+id/image"
- android:layout_below="@id/btn_ani"
- android:layout_alignParentBottom="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/sample_icon_00"
- android:scaleType="center"/>
- </LinearLayout>
- </RelativeLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
The animation XML: anim/anim.xml
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <scale xmlns:android="http://schemas.android.com/apk/res/android"
- android:fromXScale="1.0"
- android:toXScale="2.0"
- android:fromYScale="1.0"
- android:toYScale="2.0"
- android:pivotX="50%"
- android:pivotY="50%"
- android:startOffset="0"
- android:duration="400"
- android:fillBefore="true" />
Parsed in 0.002 seconds, using GeSHi 1.0.8.4

