FloatingText


Source link: https://github.com/UFreedom/FloatingText

DEPRECATED

I have developed the FloatingView ,FloatingView can make the target view floating above the anchor view with cool animation.FloatingText do the same thing, FloatingView can do, and FloatingView more convenient and powerful.so you can use FloatingView instead of FloatingText.

FloatingText

[ ]( https://bintray.com/ufreedom/maven/FloatingTextLibrary/_latestVersion)

FloatingText is a text widget that can floating above view with animation .

Now we have 'Scale Floating','Scale Floating','Curve Floating',and you can also design custom a animation.

????

Compatibility

  • Library - Android Honeycomb 3.0+
  • Sample - Android Honeycomb 3.0+

Usage:

1.Add Snapshot repository and add to dependencies:

dependencies {

 compile 'com.ufreedom.uikit:FloatingTextLibrary:0.2.0' 
}
 
  1. Use FloatingText.FloatingTextBuilder to create a FloatingText?
 FloatingText
floatingText = new FloatingText.FloatingTextBuilder(Activity)

  .textColor(Color.RED) // floating  text color

  .textSize(100)
// floating  text size

  .textContent("+1000") // floating  text content

  .offsetX(100) // the x offset  relate to the attached view

  .offsetY(100) // the y offset  relate to the attached view  

  .floatingAnimatorEffect(FloatingAnimator) // floating animation

  .floatingPathEffect(FloatingPathEffect) // floating path

  .build();
  floatingText.attach2Window();
 // let FloatingText attached to the Window

3.Start floating

floatingText.startFloating(View);
 // FloatingText do floating animation relate to the view

Customisation:

1.Coordinates

2.Floating Animation

Implements FloatingAnimator interface and do animation in the applyFloatingAnimation method?

public interface FloatingAnimator {

public void applyFloatingAnimation(FloatingTextView view);
 
}

ReboundFloatingAnimator

ReboundFloatingAnimator implements FloatingAnimator and support rebound animation.The rebound animation is Facebook's library Rebound?

There are three help methods;

  • createSpringByBouncinessAndSpeed : config rebound width bounciness and speed
  • createSpringByTensionAndFriction : config rebound width tension and friction
  • transition(float progress, float startValue, float endValue): use the method to get animated value .

progress : the progress of current animation startValue : the start value of your animation endValue : the end value of your animation

In this library : ScaleFloatingAnimator ? TranslateFloatingAnimator? BaseFloatingPathAnimator all implements ReboundFloatingAnimator interface?

For example : ScaleFloatingAnimator

public class ScaleFloatingAnimator extends ReboundFloatingAnimator {

public long duration;
  public ScaleFloatingAnimator() {

duration = 1000;
  
}

public ScaleFloatingAnimator(long duration) {

this.duration = duration;
  
}

@Override
  public void applyFloatingAnimation(final FloatingTextView view) {

Spring scaleAnim = createSpringByBouncinessAndSpeed(10, 15)

  .addListener(new SimpleSpringListener() {

@Override

public void onSpringUpdate(Spring spring) {

 float transition = transition((float) spring.getCurrentValue(), 0.0f, 1.0f);

 view.setScaleX(transition);

 view.setScaleY(transition);

}

  
}
);

ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f);

alphaAnimator.setDuration(duration);

alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

 @Override

 public void onAnimationUpdate(ValueAnimator valueAnimator) {

  view.setAlpha((Float) valueAnimator.getAnimatedValue());

 
}

}
);

scaleAnim.setEndValue(1f);

alphaAnimator.start();

  
}
  
}

3.Floating Path

Implements FloatingPathEffect and FloatingPathAnimator interface can custom you own floating path animation.

  • FloatingPath is the floating path
public interface FloatingPathEffect {

abstract FloatingPath getFloatingPath(FloatingTextView floatingTextView);
  
}

create a path and then use FloatingPath.create(Path path, boolean forceClose) to create FloatingPath. if the forceClose's value is true,the path will be forced to close .

For example?CurveFloatingPathEffect :

public class CurveFloatingPathEffect implements FloatingPathEffect {

 @Override

public FloatingPath getFloatingPath(FloatingTextView floatingTextView) {

 Path path = new Path();

 path.moveTo(0, 0);

 path.quadTo(-100, -200, 0, -300);

 path.quadTo(200, -400, 0, -500);

 return FloatingPath.create(path, false);

}
 
}

4.Floating Path Animation

After use FloatingPathEffect to define the path,Then you should implements the BaseFloatingPathAnimator interface and do path animation.

For example: CurvePathFloatingAnimator ?

public class CurvePathFloatingAnimator extends BaseFloatingPathAnimator {

@Override
  public void applyFloatingPathAnimation(final FloatingTextView view, float start, float end) {

 ValueAnimator translateAnimator = ObjectAnimator.ofFloat(start, end);

translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

 @Override

 public void onAnimationUpdate(ValueAnimator valueAnimator) {

  float value = (float) valueAnimator.getAnimatedValue();

  float pos[] = getFloatingPosition(value);

  float x = pos[0];

  float y = pos[1];

  view.setTranslationX(x);

  view.setTranslationY(y);

  
}

}
);

 translateAnimator.setDuration(3000);

translateAnimator.setStartDelay(50);

translateAnimator.start();

}
 
}
  • applyFloatingPathAnimation(final FloatingTextView view, float start, float end) :

The param 'start' is the start value of the path,and the param 'end' is the end value of the path.

  • getFloatingPosition(float progress) :

    get the current animated path value ,[0] is x?[1] is y.

Changelog

Version: 0.2.0

  • Fix the position bug - Thanks MarsVard contribution

Version: 0.1.0

  • Initial Build

License

Copyright 2015 UFreedom  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Makes it easy and simple to integrate "Attach that file" feature into your android apps.

A standalone packaging of the annotations from Google's AutoValue library.

A ViewPager that shows items from right to left for RTL locales and behaves like a regular ViewPager otherwise.

Template for Android Studio wizard for projects using Dagger.

An android library which provides a compact calendar view much like the one used in google calenders, following material design.

Simple Android widget that display a loading animation when a user clicks the button.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes