I Cant understand of the animations work the following code works, but It make the view "flash" at the end of the animation...
Any Solution ? what am I missing ?
Using java Syntax Highlighting
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.Window;
- import android.view.View.OnClickListener;
- import android.view.animation.Animation;
- import android.view.animation.AnimationUtils;
- import android.widget.ImageView;
- import android.widget.RelativeLayout;
- public class FlowPlus extends Activity {
- public static boolean isDetailsShowed = false;
- public static ImageView barre_bas;
- public static ImageView user;
- public static ImageView job;
- public static ImageView vignettes;
- public static ImageView arrow;
- public static ImageView details;
- public static RelativeLayout main;
- public static RelativeLayout details_layout;
- public static RelativeLayout.LayoutParams lp;
- private final class animationListener implements Animation.AnimationListener {
- private int type;
- private animationListener(int type) {
- this.type = type;
- }
- public void onAnimationStart(Animation animation) {
- }
- public void onAnimationEnd(Animation animation) {
- switch(this.type) {
- case 1:
- lp.leftMargin=200;
- details_layout.setLayoutParams(lp);
- System.out.println(arrow.getRight());
- arrow.setImageResource(R.drawable.arrow2);
- isDetailsShowed=true;
- break;
- case 2:
- lp.leftMargin=-200;
- details_layout.setLayoutParams(lp);
- arrow.setImageResource(R.drawable.arrow);
- isDetailsShowed=false;
- break;
- }
- }
- public void onAnimationRepeat(Animation animation) {
- }
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.main);
- final Animation slide_bot = AnimationUtils.loadAnimation(this, R.anim.slide_bot);
- slide_bot.setAnimationListener(new animationListener(0));
- final Animation slide_right = AnimationUtils.loadAnimation(this, R.anim.slide_right);
- slide_right.setAnimationListener(new animationListener(1));
- final Animation slide_left = AnimationUtils.loadAnimation(this, R.anim.slide_left);
- slide_left.setAnimationListener(new animationListener(2));
- barre_bas = (ImageView) findViewById(R.id.barre_bas);
- user = (ImageView) findViewById(R.id.user);
- arrow = (ImageView) findViewById(R.id.job);
- vignettes = (ImageView) findViewById(R.id.vignettes);
- arrow = (ImageView) findViewById(R.id.arrow);
- details_layout = (RelativeLayout) findViewById(R.id.details_layout);
- main = (RelativeLayout) findViewById(R.id.main);
- //main.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
- lp = (android.widget.RelativeLayout.LayoutParams) details_layout.getLayoutParams();
- details = (ImageView) findViewById(R.id.details);
- barre_bas.setOnClickListener(new OnClickListener() {
- public void onClick (View v) {
- barre_bas.startAnimation(slide_bot);
- }
- });
- arrow.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- if(!isDetailsShowed) {
- System.out.println(arrow.getRight());
- details_layout.startAnimation(slide_right);
- } else {
- System.out.println(arrow.getRight());
- details_layout.startAnimation(slide_left);
- }
- }
- });
- }
- }
Parsed in 0.043 seconds, using GeSHi 1.0.8.4
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="640px"
- android:layout_height="448px"
- android:id="@+id/main"
- android:background="#e6e6e6">
- <ImageView
- android:id="@+id/job"
- android:layout_width="200px"
- android:layout_height="fill_parent"
- android:background="#e6e6e6"
- />
- <ImageView
- android:id="@+id/vignettes"
- android:src="@drawable/vignettes"
- android:layout_width="420px"
- android:layout_height="fill_parent"
- android:layout_toRightOf="@id/job"
- android:layout_marginLeft="20px"
- android:scaleType="fitXY"
- />
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="420px"
- android:layout_height="448px"
- android:id="@+id/details_layout"
- android:layout_marginLeft="-200px">
- <ImageView
- android:id="@+id/details"
- android:layout_width="400px"
- android:layout_height="448px"
- android:background="#e6e6e6"
- />
- <ImageView
- android:id="@+id/arrow"
- android:src="@drawable/arrow"
- android:layout_width="20px"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@id/details"
- android:layout_marginTop="188px"
- />
- </RelativeLayout>
- <ImageView
- android:id="@+id/barre_bas"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:src="@drawable/barre_bas"
- android:layout_alignBottom="@id/job"
- />
- <ImageView
- android:id="@+id/user"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/user"
- android:layout_alignRight="@id/vignettes"
- android:layout_marginLeft="-152px"
- />
- </RelativeLayout>
Parsed in 0.007 seconds, using GeSHi 1.0.8.4
Regards, Loules

