您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“XamarinAndroid中在RecylerView子元素進(jìn)行添加/刪除操作時(shí)如何實(shí)現(xiàn)透明動(dòng)畫效果”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“XamarinAndroid中在RecylerView子元素進(jìn)行添加/刪除操作時(shí)如何實(shí)現(xiàn)透明動(dòng)畫效果”這篇文章吧。
如果在RecyclerViewAnimators.Animators中沒有所需要的動(dòng)畫效果,就可以自定義一個(gè)。此時(shí),需要讓自定義的動(dòng)畫繼承BaseItemAnimator抽象類。
【示例1-2】下面以RecylerViewAnimatorsItemAnimator項(xiàng)目為基礎(chǔ),在RecylerView子元素進(jìn)行添加/刪除操作時(shí),實(shí)現(xiàn)透明動(dòng)畫效果。具體的操作步驟如下:
(1)創(chuàng)建一個(gè)類文件,命名為AlphaAnimator。
(2)打開AlphaAnimator.cs文件,實(shí)現(xiàn)透明度動(dòng)畫。代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.V4.View;
using Android.Support.V7.Widget;
using Android.Views;
using Android.Widget;
using RecyclerViewAnimators.Animators;
namespace RecylerViewAnimatorsItemAnimator
{
public class AlphaAnimator : BaseItemAnimator
{
public AlphaAnimator()
{
}
//添加子元素時(shí)調(diào)用的動(dòng)畫
protected override void AnimateAddImpl(RecyclerView.ViewHolder holder)
{
ViewCompat.Animate(holder.ItemView)
.Alpha(1)
.SetDuration(AddDuration)
.Start();
}
//刪除子元素時(shí)調(diào)用的動(dòng)畫
protected override void AnimateRemoveImpl(RecyclerView.ViewHolder holder)
{
ViewCompat.Animate(holder.ItemView)
.SetDuration(RemoveDuration)
.Alpha(0)
.Start();
}
}
}
以上是“XamarinAndroid中在RecylerView子元素進(jìn)行添加/刪除操作時(shí)如何實(shí)現(xiàn)透明動(dòng)畫效果”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。