Android自定義FloatingText仿點(diǎn)贊+1特效
本文實(shí)例為大家分享了Android自定義View,可以仿點(diǎn)贊往上飄+1的一個(gè)特效,或者點(diǎn)擊加入購(gòu)物車商品拋物線特效。
FloatingText 是一個(gè)能夠在任何控件之上執(zhí)行漂浮效果動(dòng)畫的控件。
原文github地址
效果圖
1. AndroidStudio使用
dependencies { compile 'com.ufreedom.uikit:FloatingTextLibrary:0.2.0' }
2. 使用
FloatingText floatingText = new FloatingText.FloatingTextBuilder(Activity) .textColor(Color.RED) // 漂浮字體的顏色 .textSize(100) // 浮字體的大小 .textContent("+1000") // 浮字體的內(nèi)容 .offsetX(100) // FloatingText 相對(duì)其所貼附View的水平位移偏移量 .offsetY(100) // FloatingText 相對(duì)其所貼附View的垂直位移偏移量 .floatingAnimatorEffect(FloatingAnimator) // 漂浮動(dòng)畫 .floatingPathEffect(FloatingPathEffect) // 漂浮的路徑 .build(); floatingText.attach2Window(); //將FloatingText貼附在Window上 //啟動(dòng)漂浮效果 floatingText.startFloating(View); // 傳入一個(gè)View,F(xiàn)loatingText 就會(huì)相對(duì)于這個(gè)View執(zhí)行漂浮效果
自定義漂浮動(dòng)畫
通過(guò)實(shí)現(xiàn) FloatingAnimator 接口可以實(shí)現(xiàn)自定義漂浮動(dòng)畫,詳情查看原github。
自定義漂浮路徑
通過(guò)實(shí)現(xiàn) FloatingPathEffect 和 FloatingPathAnimator 可以自定義路徑動(dòng)畫
FloatingPath 代表浮動(dòng)路徑
JAVA
// +1 向上移動(dòng)效果 final View layoutTranslateFloating = findViewById(R.id.layoutTranslateView); final View translateFloatingView = findViewById(R.id.translateView); final FloatingText translateFloatingText = new FloatingText.FloatingTextBuilder(MainActivity.this) .textColor(Color.RED) .textSize(100) .textContent("+1") .build(); translateFloatingText.attach2Window(); assert layoutTranslateFloating != null; layoutTranslateFloating.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { translateFloatingText.startFloating(translateFloatingView); } }); //+1 放大效果 View layoutScaleView = findViewById(R.id.layoutScaleView); final View scaleView = findViewById(R.id.scaleView); final FloatingText scaleFloatingText = new FloatingText.FloatingTextBuilder(MainActivity.this) .textColor(Color.parseColor("#7ED321")) .textSize(100) .offsetY(-100) .floatingAnimatorEffect(new ScaleFloatingAnimator()) .textContent("+1") .build(); scaleFloatingText.attach2Window(); assert scaleView != null; assert layoutScaleView != null; layoutScaleView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { scaleFloatingText.startFloating(scaleView); } }); //自定義 螺旋上升動(dòng)畫 final FloatingText cubicFloatingText = new FloatingText.FloatingTextBuilder(MainActivity.this) .textColor(Color.RED) .textSize(100) .floatingAnimatorEffect(new CurvePathFloatingAnimator()) .floatingPathEffect(new CurveFloatingPathEffect()) .textContent("Hello! ") .build(); cubicFloatingText.attach2Window(); View layoutCurveView = findViewById(R.id.layoutCurveView); final View curveView = findViewById(R.id.curveView); assert curveView != null; assert layoutCurveView != null; layoutCurveView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { cubicFloatingText.startFloating(curveView); } });
XML
<FrameLayout android:id="@+id/layoutTranslateView" android:layout_width="234.4dp" android:layout_height="80dp" android:layout_alignParentLeft="true" android:layout_centerHorizontal="true" android:layout_marginTop="50dp" > <TextView android:id="@+id/translateView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="20dp" android:text="Translate Floating" android:textColor="@android:color/white" /> </FrameLayout>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android使用SurfaceView實(shí)現(xiàn)飄贊動(dòng)畫
- Android仿直播特效之點(diǎn)贊飄心效果
- Android貝塞爾曲線實(shí)現(xiàn)直播點(diǎn)贊效果
- Android實(shí)現(xiàn)朋友圈點(diǎn)贊列表
- Android自定義ViewGroup實(shí)現(xiàn)堆疊頭像的點(diǎn)贊Layout
- Android中使用PopupWindow 仿微信點(diǎn)贊和評(píng)論彈出
- Android實(shí)現(xiàn)點(diǎn)贊動(dòng)畫(27)
- Android PraiseTextView實(shí)現(xiàn)朋友圈點(diǎn)贊功能
- Android listview點(diǎn)贊問(wèn)題分析
- Android中Listview點(diǎn)贊功能的實(shí)現(xiàn)
- 簡(jiǎn)單實(shí)用的Android UI微博動(dòng)態(tài)點(diǎn)贊效果
- Android項(xiàng)目開(kāi)發(fā) 教你實(shí)現(xiàn)Periscope點(diǎn)贊效果
- Android控件實(shí)現(xiàn)直播App點(diǎn)贊飄心動(dòng)畫
相關(guān)文章
Android實(shí)現(xiàn)仿Windows7圖片預(yù)覽窗格效果
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)仿Windows7圖片預(yù)覽窗格效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12解決Android中自定義DialogFragment解決寬度和高度問(wèn)題
Android中自定義DialogFragment解決寬度和高度問(wèn)題但是我們很多時(shí)候想把DialogFragment的高度固定,那么我們需要設(shè)置DialogFragment的高度,在Fragment的onResume()聲明周期方法中設(shè)置window的寬高即可2017-12-12Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫(kù)訪問(wèn)實(shí)例
下面小編就為大家分享一篇Rxjava2_Flowable_Sqlite_Android數(shù)據(jù)庫(kù)訪問(wèn)實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-02-02詳解Flutter Image組件如何處理圖片加載過(guò)程中的錯(cuò)誤
在Flutter中,Image組件可以通過(guò)監(jiān)聽(tīng)加載過(guò)程中的錯(cuò)誤來(lái)處理圖片加載過(guò)程中的錯(cuò)誤,本文小編將給大家詳細(xì)介紹了Flutter Image組件是如何處理圖片加載過(guò)程中的錯(cuò)誤,文中有詳細(xì)的代碼示例供大家參考,需要的朋友可以參下2023-10-10Android獲取手機(jī)配置信息具體實(shí)現(xiàn)代碼
下面為大家介紹下使用android獲取手機(jī)配置信息的具體過(guò)程,感興趣的朋友可以參考下哈,希望對(duì)你有所幫助2013-06-06Android解決getExternalStorageDirectory在29后廢棄問(wèn)題(推薦)
這篇文章主要介紹了Android解決getExternalStorageDirectory在29后廢棄問(wèn)題(推薦),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-02Android Studio 運(yùn)行按鈕灰色的完美解決方法
今天新建項(xiàng)目的時(shí)候突然發(fā)現(xiàn)編譯后運(yùn)行按鈕為灰色,今天小編給大家?guī)?lái)了Android Studio 運(yùn)行按鈕灰色的完美解決方法,非常不錯(cuò),對(duì)大家的需要或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2020-10-10