上万部爽片,立即观看,在线观看,日韩av无码久久精品免费,欧美性受xxxx喷潮,欧洲男同gay,日韩精品一区二区三区

十年專注于品牌網(wǎng)站建設 十余年專注于網(wǎng)站建設_小程序開發(fā)_APP開發(fā),低調(diào)、敢創(chuàng)新、有情懷!
南昌百恒網(wǎng)絡微信公眾號 掃一掃關注
小程序
tel-icon全國服務熱線:400-680-9298,0791-88117053
掃一掃關注百恒網(wǎng)絡微信公眾號
掃一掃打開百恒網(wǎng)絡微信小程序

百恒網(wǎng)絡

南昌百恒網(wǎng)絡

如何創(chuàng)建circular reveal動畫特效?

百恒網(wǎng)絡 2017-08-17 5913

南昌APP開發(fā)中,同行朋友都知道,material design引入了很多漂亮的動畫特效。實現(xiàn)時,有些很容易,有些比較困難,需要花點力氣。不過,如果能善用Android提供的便利工具,事情就好辦得多。

就拿circular reveal動畫來說,circular reveal動畫看起來就像墨滴在一張紙上向外快速擴散。從一個交互點出發(fā)(通常是用戶的按壓點),視圖或是一段文字向外擴散式顯現(xiàn)。模擬效果如圖1所示。

circular reveal動畫特效演示

圖1 circular reveal動畫特效演示

那么如何創(chuàng)建circular reveal動畫特效呢?其實也不難,要創(chuàng)建circular reveal動畫特效,可調(diào)用ViewAnimationUtils的createCircularReveal(...) 方法。該方法有5個參數(shù):

static Animator createCircularReveal(View view, int centerX, int centerY,float startRadius, float endRadius)

第一個View參數(shù)就是要向外擴散顯現(xiàn)的視圖。在圖1中,這個視圖就是和 BeatBoxFragment寬高一致的紅色實心視圖。如果動畫從startRadius(值為0)圓點開始到 endRadius結束,這個紅點視圖會先變?yōu)橥该鳡顟B(tài),并隨著一個不斷放大的圓慢慢顯現(xiàn)。centerX 和centerY是這個圓的圓點坐標(也就是View的坐標)。該方法會返回一個Animator。

此外,南昌APP制作開發(fā)公司-百恒網(wǎng)絡認為,circular reveal動畫應該開始于用戶手指在屏幕上的觸點。所以,首先要找到用戶點擊視圖的坐標,具體操作看如下代碼。

找到點擊視圖坐標

@Override

public void onClick(View clickSource) {

int[] clickCoords = new int[2];

// Find the location of clickSource on the screen

clickSource.getLocationOnScreen(clickCoords);

// Tweak that location so that it points at the center of the view,

// not the corner

clickCoords[0] += clickSource.getWidth() / 2;

clickCoords[1] += clickSource.getHeight() / 2;

performRevealAnimation(mViewToReveal, clickCoords[0], clickCoords[1]);

}

然后開始執(zhí)行circular reveal動畫,如下代碼所示。

執(zhí)行circular reveal動畫

private void performRevealAnimation(View view, int screenCenterX, int screenCenterY) {

// Find the center relative to the view that will be animated

int[] animatingViewCoords = new int[2];

view.getLocationOnScreen(animatingViewCoords);

int centerX = screenCenterX - animatingViewCoords[0];

int centerY = screenCenterY - animatingViewCoords[1];

// Find the maximum radius

Point size = new Point();

getActivity().getWindowManager().getDefaultDisplay().getSize(size);

int maxRadius = size.y;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

ViewAnimationUtils.createCircularReveal(view, centerX, centerY, 0, maxRadius)

.start();

}

}

注意,成功調(diào)用createCircularReveal(...)方法的前提條件是,布局中已有目標視圖。

以上便是本公司為大家介紹的關于在南昌APP開發(fā)中創(chuàng)建circular reveal動畫特效的方法,這種特效的實現(xiàn)比較簡單,大家也應該比較好理解,如果大家還有哪些不明白的地方,可隨時來電和我們聯(lián)系,百恒專業(yè)為您講解。此外,若有需要開發(fā)APP的朋友,百恒網(wǎng)絡期待與您的合作,我們將隨時為您效勞!

400-680-9298,0791-88117053
掃一掃關注百恒網(wǎng)絡微信公眾號
掃一掃打開百恒網(wǎng)絡小程序

歡迎您的光顧,我們將竭誠為您服務×

售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售后服務 售后服務
 
售后服務 售后服務
 
備案專線 備案專線
 
×