android图像视图缩放动画

我想知道如何缩放徽标的动画并移动其位置?

我有一个if语句运行一些检查,然后当它完成时,我希望它缩小图像视图(徽标)并将其向上移动.

继承我的布局

<?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"
    android:orientation="vertical"
    android:background="@drawable/bg_default" >

    <ImageView
        android:id="@+id/su_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="34dp"
        android:src="@drawable/su_logo" 
        android:contentDescription="@string/cd_su_logo"/>

    <ImageView
        android:id="@+id/su_shirts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/su_shirts"
        android:contentDescription="@string/cd_su_shirts" />

</RelativeLayout>

继承我的java

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_initialsetup);
        preChecks();
    }

public void preChecks(){
    //check for internet connection

    //check version
    String curVersion = getResources().getString(R.string.app_versionCode);
    int curVer = Integer.parseInt(curVersion);  
    String LiveVersion = "100";
    int liveVer = Integer.parseInt(LiveVersion);

    if(curVer < liveVer) Log.v("setup","There is a new version");  
    else { 

        //scale animation


    }   




}

解决方法

您可以通过在AnimationSet中一起应用ScaleAnimation和TranslateAnimation来实现
// Scaling
Animation scale = new ScaleAnimation(fromXscale,toXscale,fromYscale,toYscale,Animation.RELATIVE_TO_SELF,0.5f,0.5f);
// 1 second duration
scale.setDuration(1000);
// Moving up
Animation slideUp = new TranslateAnimation(fromX,toX,fromY,toY);
// 1 second duration
slideUp.setDuration(1000);
// Animation set to join both scaling and moving
AnimationSet animset = new AnimationSet(true);
animset.setFillEnabled(true);
animset.addAnimation(scale);
animset.addAnimation(slideUp);
// Launching animation set
logo.startAnimation(animset);

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...