估值器 Evaluator

  • 內(nèi)容
    接口 TypeEvaluator <T>
    常見(jiàn)估值器
    自定義估值器

  • 接口 TypeEvaluator <T>
    本質(zhì)是:根據(jù)比例 計(jì)算具體值
    This function returns the result of linearly interpolating the start and end values, with fraction representing the proportion between the start and end values.

/**
 * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators
 * allow developers to create animations on arbitrary property types, by allowing them to supply
 * custom evaluators for types that are not automatically understood and used by the animation
 * system.
 *
 * @see ValueAnimator#setEvaluator(TypeEvaluator)
 */
public interface TypeEvaluator<T> {

    /**
     * This function returns the result of linearly interpolating the start and end values, with
     * <code>fraction</code> representing the proportion between the start and end values. The
     * calculation is a simple parametric calculation: <code>result = x0 + t * (x1 - x0)</code>,
     * where <code>x0</code> is <code>startValue</code>, <code>x1</code> is <code>endValue</code>,
     * and <code>t</code> is <code>fraction</code>.
     *
     * @param fraction   The fraction from the starting to the ending values
     * @param startValue The start value.
     * @param endValue   The end value.
     * @return A linear interpolation between the start and end values, given the
     *         <code>fraction</code> parameter.
     */
    public T evaluate(float fraction, T startValue, T endValue);

}
  • 常用估值器
/**
 * This evaluator can be used to perform type interpolation between <code>int</code> values.
 */
public class IntEvaluator implements TypeEvaluator<Integer> {

    /**
     * This function returns the result of linearly interpolating the start and end values, with
     * <code>fraction</code> representing the proportion between the start and end values. The
     * calculation is a simple parametric calculation: <code>result = x0 + t * (v1 - v0)</code>,
     * where <code>x0</code> is <code>startValue</code>, <code>x1</code> is <code>endValue</code>,
     * and <code>t</code> is <code>fraction</code>.
     *
     * @param fraction   The fraction from the starting to the ending values
     * @param startValue The start value; should be of type <code>int</code> or
     *                   <code>Integer</code>
     * @param endValue   The end value; should be of type <code>int</code> or <code>Integer</code>
     * @return A linear interpolation between the start and end values, given the
     *         <code>fraction</code> parameter.
     */
    public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
        int startInt = startValue;
        return (int)(startInt + fraction * (endValue - startInt));
    }
}
  • 自定義估值器
    重寫(xiě)evaluate即可
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末悠瞬,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子涯捻,更是在濱河造成了極大的恐慌浅妆,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,406評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件障癌,死亡現(xiàn)場(chǎng)離奇詭異凌外,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)涛浙,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,732評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門(mén)康辑,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人轿亮,你說(shuō)我怎么就攤上這事疮薇。” “怎么了我注?”我有些...
    開(kāi)封第一講書(shū)人閱讀 163,711評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵按咒,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我但骨,道長(zhǎng)励七,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,380評(píng)論 1 293
  • 正文 為了忘掉前任奔缠,我火速辦了婚禮掠抬,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘校哎。我一直安慰自己两波,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,432評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著雨女,像睡著了一般谚攒。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上氛堕,一...
    開(kāi)封第一講書(shū)人閱讀 51,301評(píng)論 1 301
  • 那天馏臭,我揣著相機(jī)與錄音,去河邊找鬼讼稚。 笑死括儒,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的锐想。 我是一名探鬼主播帮寻,決...
    沈念sama閱讀 40,145評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼赠摇!你這毒婦竟也來(lái)了固逗?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 39,008評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤藕帜,失蹤者是張志新(化名)和其女友劉穎烫罩,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體洽故,經(jīng)...
    沈念sama閱讀 45,443評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡贝攒,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,649評(píng)論 3 334
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了时甚。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片隘弊。...
    茶點(diǎn)故事閱讀 39,795評(píng)論 1 347
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖荒适,靈堂內(nèi)的尸體忽然破棺而出梨熙,到底是詐尸還是另有隱情,我是刑警寧澤吻贿,帶...
    沈念sama閱讀 35,501評(píng)論 5 345
  • 正文 年R本政府宣布串结,位于F島的核電站,受9級(jí)特大地震影響舅列,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜卧蜓,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,119評(píng)論 3 328
  • 文/蒙蒙 一帐要、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧弥奸,春花似錦榨惠、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,731評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)耽装。三九已至,卻和暖如春期揪,著一層夾襖步出監(jiān)牢的瞬間掉奄,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,865評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工凤薛, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留姓建,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,899評(píng)論 2 370
  • 正文 我出身青樓缤苫,卻偏偏與公主長(zhǎng)得像速兔,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子活玲,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,724評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,325評(píng)論 0 10
  • 本筆記的原文本鏈接 Property Animation Overview 屬性動(dòng)畫(huà)總覽 The property...
    Jaesoon閱讀 1,101評(píng)論 2 3
  • 以前涣狗,剛在一起那會(huì)兒,大三那會(huì)兒舒憾,基本每天都有很多課屑柔,而空閑的時(shí)候都會(huì)接到你的電話,我根本就沒(méi)怎么給你打過(guò)電話珍剑。...
    我的我閱讀 249評(píng)論 0 0
  • 知道查理.芒格毫無(wú)疑問(wèn)是因?yàn)榘头铺氐穑鳛橐粋€(gè)和巴菲特合作四十多年的伙伴,必然有其過(guò)人之處招拙。芒格的投資理念必然與巴菲...
    龍暢天下閱讀 202評(píng)論 1 1
  • 也許你很難相信 一群做鄉(xiāng)鎮(zhèn)物流的小伙還是一群熱愛(ài)分享鄉(xiāng)村美食的吃貨 每天下午3:30興國(guó)縣城?社富鄉(xiāng)别凤,途徑杰村的路...
    不憶悅乎閱讀 418評(píng)論 0 2