属性动画图片点击弹出

package com.bawei.gaoying;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationSet;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;
import java.util.jar.Pack200;



public class BaseAda extends BaseAdapter {

    private List<Bean> list;
    private Context context;

    public BaseAda(List<Bean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        View view1 = LayoutInflater.from(context).inflate(R.layout.item, null);
        TextView  tit= view1.findViewById(R.id.tit);
        final ImageView jia = view1.findViewById(R.id.jia);
        TextView tv_tit = view1.findViewById(R.id.tv_tit);

        final ImageView copylink1 = view1.findViewById(R.id.copylink1);
        final ImageView report1 = view1.findViewById(R.id.report1);
        final ImageView shiled1 = view1.findViewById(R.id.shiled1);

        tit.setText(list.get(i).getTitle());
        tv_tit.setText(list.get(i).getContext());


        //动画设置
        jia.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(!b)
                {
                    jia(report1,2);
                    jia(copylink1,3);
                    jia(shiled1,4);
                    jia.setImageResource(R.mipmap.icon_packup);
                    b=true;
                }
                else
                {
                    jia2(report1,2);
                    jia2(copylink1,3);
                    jia2(shiled1,4);
                    jia.setImageResource(R.mipmap.icon_open);
                    b=false;
                }
            }
        });
        return view1;
    }


    private boolean b=false;
    private void jia(View view,int b) {
        int width = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth();
        ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(view,"X",width-view.getWidth(),width-view.getWidth()*b);
        ObjectAnimator objectAnimator1=ObjectAnimator.ofFloat(view,"rotation",360,0);
        AnimatorSet set=new AnimatorSet();
        set.play(objectAnimator).with(objectAnimator1);
        set.setDuration(2000);
        set.start();
    }

    private void jia2(View view,int b) {
        int width = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth();
        ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(view,"X",width-view.getWidth()*b,width-view.getWidth());
        ObjectAnimator objectAnimator1=ObjectAnimator.ofFloat(view,"rotation",0,360);
        AnimatorSet set=new AnimatorSet();
        set.play(objectAnimator).with(objectAnimator1);
        set.setDuration(2000);
        set.start();
    }

}




布局:

<RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="50dip">

         <ImageView
             android:id="@+id/img"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignParentLeft="true"
             android:src="@mipmap/ic_launcher"
             />

           <TextView
               android:id="@+id/tit"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_alignParentLeft="true"
               android:layout_centerVertical="true"
               android:layout_marginLeft="60dip"
               android:text="标题"
               />


         <ImageView
             android:id="@+id/shiled1"
             android:layout_width="30dip"
             android:layout_centerVertical="true"
             android:layout_height="30dip"
             android:layout_alignParentRight="true"
             android:src="@mipmap/shiled1"
             />

         <ImageView
             android:id="@+id/report1"
             android:layout_width="30dip"
             android:layout_centerVertical="true"
             android:layout_height="30dip"
             android:layout_alignParentRight="true"
             android:src="@mipmap/report1"
             />


         <ImageView
             android:id="@+id/copylink1"
             android:layout_width="30dip"
             android:layout_centerVertical="true"
             android:layout_height="30dip"
             android:layout_alignParentRight="true"
             android:src="@mipmap/copylink1"
             />


         <ImageView
             android:id="@+id/jia"
             android:layout_width="30dip"
             android:layout_centerVertical="true"
             android:layout_height="30dip"
             android:layout_alignParentRight="true"
             android:src="@mipmap/icon_open"
             />

     </RelativeLayout>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值