第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

關(guān)于點(diǎn)擊紅點(diǎn),圖標(biāo)扇形出現(xiàn)的代碼實(shí)現(xiàn),貼上自己的代碼

雖然還有很多需要優(yōu)化的地方,但也算實(shí)現(xiàn)了這個(gè)功能,需要的童鞋可以參考下

import?android.animation.AnimatorSet;
import?android.animation.ObjectAnimator;
import?android.app.Activity;
import?android.os.Bundle;
import?android.view.View;
import?android.view.animation.BounceInterpolator;
import?android.widget.ImageView;
import?android.widget.Toast;

import?java.util.ArrayList;
import?java.util.List;

public?class?MainActivity?extends?Activity?implements?View.OnClickListener?{

????//創(chuàng)建數(shù)組存儲圖片id
????private?int[]?res?=?{R.id.imageView_a,?R.id.imageView_b,?R.id.imageView_c,?R.id.imageView_d,
????????????R.id.imageView_e,?R.id.imageView_f,?R.id.imageView_g,?R.id.imageView_h};


????//創(chuàng)建列表list存儲圖片
????private?List<ImageView>?imageViewList?=?new?ArrayList<ImageView>();

????private?boolean?flag?=?true;

????private?float?angle;

????private?final?int?r?=?380;

????@Override
????protected?void?onCreate(Bundle?savedInstanceState)?{
????????super.onCreate(savedInstanceState);
????????setContentView(R.layout.my_activity);
????????for?(int?i?=?0;?i?<?res.length;?i++)?{
????????????ImageView?imageView?=?(ImageView)?findViewById(res[i]);
????????????imageView.setOnClickListener(this);
????????????imageViewList.add(imageView);

????????}
????}

????@Override
????public?void?onClick(View?v)?{
????????switch?(v.getId())?{
????????????case?R.id.imageView_a:
????????????????if?(flag)?{
????????????????????startAnim();
????????????????}?else?{
????????????????????closeAnim();
????????????????}

????????????????break;
????????????default:
????????????????Toast.makeText(MainActivity.this,?"clicked"?+?v.getId(),?Toast.LENGTH_SHORT).show();
????????????????break;
????????}
????}

????private?void?startAnim()?{
????????angle?=?(float)?Math.PI?/?(2?*?(res.length?-?2));
????????for?(int?i?=?1;?i?<?res.length;?i++)?{
????????????float?xLength?=?(float)?(r?*?Math.sin((i?-?1)?*?angle));
????????????float?yLength?=?(float)?(r?*?Math.cos((i?-?1)?*?angle));
????????????ObjectAnimator?animator1?=?ObjectAnimator.ofFloat(imageViewList.get(i),
????????????????????"translationX",?0F,?-xLength);
????????????ObjectAnimator?animator2?=?ObjectAnimator.ofFloat(imageViewList.get(i),
????????????????????"translationY",?0F,?-yLength);
????????????AnimatorSet?set?=?new?AnimatorSet();
????????????set.playTogether(animator1,?animator2);
????????????set.setDuration(500);
????????????set.setInterpolator(new?BounceInterpolator());
????????????set.setStartDelay(i?*?200);
????????????set.start();
????????????flag?=?false;

????????}
????}

????private?void?closeAnim()?{
????????angle?=?(float)?Math.PI?/?(2?*?(res.length?-?2));
????????for?(int?i?=?1;?i?<?res.length;?i++)?{
????????????float?xLength?=?(float)?(r?*?Math.sin((i?-?1)?*?angle));
????????????float?yLength?=?(float)?(r?*?Math.cos((i?-?1)?*?angle));
????????????ObjectAnimator?animator1?=?ObjectAnimator.ofFloat(imageViewList.get(i),
????????????????????"translationX",?-xLength,?0F);
????????????ObjectAnimator?animator2?=?ObjectAnimator.ofFloat(imageViewList.get(i),
????????????????????"translationY",?-yLength,?0F);
????????????AnimatorSet?set?=?new?AnimatorSet();
????????????set.playTogether(animator1,?animator2);
????????????set.setDuration(500);
????????????set.setInterpolator(new?BounceInterpolator());
????????????set.setStartDelay((res.length-i)?*?200);
????????????set.start();
????????????flag?=?true;
????????}

????}
}
覺得有用的話,記得采納回答喲

正在回答

1 回答

這是效果圖http://img1.sycdn.imooc.com//5774a8830001aef104640695.jpg

1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Android屬性動畫賞析
  • 參與學(xué)習(xí)       37222    人
  • 解答問題       77    個(gè)

本次課程,將向你介紹如何使用屬性動畫做出更好的動畫

進(jìn)入課程

關(guān)于點(diǎn)擊紅點(diǎn),圖標(biāo)扇形出現(xiàn)的代碼實(shí)現(xiàn),貼上自己的代碼

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號