• 动画示例


    图片实现由由远到近的效果

         ImageView imageView = (ImageView)findViewById(R.id.frame_image);
            ScaleAnimation scaleAnim = new ScaleAnimation(1.0f,1.2f,1.0f,1.2f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0.5f);
            scaleAnim.setFillAfter(true);
            scaleAnim.setInterpolator(new BounceInterpolator());
            scaleAnim.setDuration(6000);
            scaleAnim.setRepeatMode(Animation.REVERSE);
            scaleAnim.setRepeatCount(Animation.INFINITE);//无限循环
            imageView.startAnimation(scaleAnim);

    加载框动画

         ImageView imageView = (ImageView)findViewById(R.id.loading);
    
            RotateAnimation rotateAnim = new RotateAnimation(0,360, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
            rotateAnim.setRepeatCount(Animation.INFINITE);
            rotateAnim.setDuration(2000);
            rotateAnim.setInterpolator(new LinearInterpolator());
            imageView.startAnimation(rotateAnim);

    扫描动画

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:duration="3000">
        <scale
                android:repeatCount="infinite"
                android:fromXScale="1.0"
                android:fromYScale="1.0"
                android:pivotX="50%"
                android:pivotY="50%"
                android:toXScale="3"
                android:toYScale="3"/>
        <alpha
                android:repeatCount="infinite" 
                android:fromAlpha="0.4"
                android:toAlpha="0"/>
    </set>  
    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="com.loaderman.customviewdemo.MainActivity">
    
        <ImageView
            android:id="@+id/circle1"
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:layout_gravity="center"
            android:layout_marginTop="30dp"
            android:src="@drawable/scan_cirle"/>
    
        <ImageView
            android:id="@+id/circle2"
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:layout_gravity="center"
            android:layout_marginTop="30dp"
            android:clickable="true"
            android:src="@drawable/scan_cirle"/>
    
        <ImageView
            android:id="@+id/circle3"
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:layout_gravity="center"
            android:layout_marginTop="30dp"
            android:clickable="true"
            android:src="@drawable/scan_cirle"/>
    
        <ImageView
            android:id="@+id/circle4"
            android:layout_width="140dp"
            android:layout_height="140dp"
            android:layout_gravity="center"
            android:layout_marginTop="30dp"
            android:clickable="true"
            android:src="@drawable/scan_cirle"/>
    
        <TextView
            android:id="@+id/start_can"
            android:layout_width="155dp"
            android:layout_height="155dp"
            android:layout_gravity="center"
            android:layout_marginTop="30dp"
            android:background="@drawable/scan_cover"/>
    
    
    </FrameLayout>
    package com.loaderman.customviewdemo;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.ImageView;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            final Animation animation1 = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale_alpha_anim);
            final Animation animation2 = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale_alpha_anim);
            final Animation animation3 = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale_alpha_anim);
            final Animation animation4 = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale_alpha_anim);
    
            final ImageView circle1 = (ImageView)findViewById(R.id.circle1);
            final ImageView circle2 = (ImageView)findViewById(R.id.circle2);
            final ImageView circle3 = (ImageView)findViewById(R.id.circle3);
            final ImageView circle4 = (ImageView)findViewById(R.id.circle4);
    
            findViewById(R.id.start_can).setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
    
                    circle1.startAnimation(animation1);
    
                    animation2.setStartOffset(600);//延迟动画开始时间
                    circle2.startAnimation(animation2);
    
                    animation3.setStartOffset(1200);
                    circle3.startAnimation(animation3);
    
                    animation4.setStartOffset(1800);
                    circle4.startAnimation(animation4);
                }
            });
    
        }
    }

    效果:

  • 相关阅读:
    xsd的解释说明
    SDUT 2498-AOE网上的关键路径(spfa+字典序路径)
    java实现各种数据统计图(柱形图,饼图,折线图)
    软件測试计划模板
    范式图形辨析
    Android做法说明(3)---Fragment使用app袋或v4包解析
    登录同步多个副本如何实现的拷贝数发生变化分布式
    ZOJ1463:Brackets Sequence(间隙DP)
    jquery php 百度搜索框智能提示效果
    Hibernate在关于一对多,多对一双向关联映射
  • 原文地址:https://www.cnblogs.com/loaderman/p/10195209.html
Copyright © 2020-2023  润新知