国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android自定義FloatingText仿點贊+1特效

2019-10-22 18:13:34
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Android自定義View,可以仿點贊往上飄+1的一個特效,或者點擊加入購物車商品拋物線特效。

FloatingText 是一個能夠在任何控件之上執行漂浮效果動畫的控件。

原文github地址

效果圖

Android,FloatingText,點贊

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") // 浮字體的內容  .offsetX(100) // FloatingText 相對其所貼附View的水平位移偏移量  .offsetY(100) // FloatingText 相對其所貼附View的垂直位移偏移量  .floatingAnimatorEffect(FloatingAnimator) // 漂浮動畫  .floatingPathEffect(FloatingPathEffect) // 漂浮的路徑  .build();floatingText.attach2Window(); //將FloatingText貼附在Window上//啟動漂浮效果floatingText.startFloating(View); // 傳入一個View,FloatingText 就會相對于這個View執行漂浮效果

自定義漂浮動畫
通過實現 FloatingAnimator 接口可以實現自定義漂浮動畫,詳情查看原github。

自定義漂浮路徑

通過實現 FloatingPathEffect 和 FloatingPathAnimator 可以自定義路徑動畫

FloatingPath 代表浮動路徑

JAVA

// +1 向上移動效果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);      }    });//自定義 螺旋上升動畫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>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武清区| 湘乡市| 拜泉县| 班戈县| 汉阴县| 齐齐哈尔市| 普兰店市| 天等县| 高阳县| 清新县| 山丹县| 镇宁| 磐安县| 信丰县| 北京市| 东海县| 昌江| 南丹县| 晋中市| 贵港市| 东光县| 方城县| 涟水县| 苍南县| 余干县| 九龙坡区| 花莲市| 公主岭市| 衡南县| 莱芜市| 新乡市| 东阳市| 贡嘎县| 和平县| 昭苏县| 天峻县| 安达市| 平乐县| 红河县| 青海省| 双桥区|