Convert Figma logo to code with AI

txusballesteros logobubbles-for-android

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

1,481
281
1,481
29

Top Related Projects

Android like button with delightful star animation inspired by Twitter's heart. See blog post for description.

explosive dust effect for views

2,710

Configurable animations based on points

2,277

A Particle System for standard Android UI: http://plattysoft.github.io/Leonids/

5,436

A Java library that models spring dynamics and adds real world physics to your app.

Render After Effects animations natively on Android and iOS, Web, and React Native

Quick Overview

Bubbles for Android is an open-source library that allows developers to easily add floating bubble widgets to their Android applications. These bubbles can be dragged around the screen and expanded to reveal additional content, similar to Facebook Messenger's chat heads feature.

Pros

  • Easy integration into existing Android projects
  • Customizable appearance and behavior of bubbles
  • Smooth animations and user interactions
  • Lightweight library with minimal impact on app performance

Cons

  • Limited documentation and examples
  • Not actively maintained (last update was in 2017)
  • May require additional work to ensure compatibility with newer Android versions
  • Potential conflicts with system-level bubble notifications introduced in Android 11

Code Examples

  1. Creating a simple bubble:
val bubble = BubbleLayout(context)
bubble.setIcon(ContextCompat.getDrawable(context, R.drawable.ic_bubble))
bubbleView.addView(bubble)
  1. Adding a click listener to a bubble:
bubble.setOnBubbleClickListener {
    Toast.makeText(context, "Bubble clicked!", Toast.LENGTH_SHORT).show()
}
  1. Customizing bubble appearance:
bubble.apply {
    setBubbleColor(ContextCompat.getColor(context, R.color.bubble_color))
    setRippleEffect(true)
    setRippleColor(ContextCompat.getColor(context, R.color.ripple_color))
}

Getting Started

  1. Add the JitPack repository to your project's build.gradle file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.txusballesteros:bubbles-for-android:1.2.1'
}
  1. In your layout XML, add the BubbleLayout:
<com.txusballesteros.bubbles.BubbleLayout
    android:id="@+id/bubble"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
  1. In your Activity or Fragment, initialize and customize the bubble:
val bubble = findViewById<BubbleLayout>(R.id.bubble)
bubble.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_bubble))
bubble.setOnBubbleClickListener {
    // Handle bubble click
}

Competitor Comparisons

Android like button with delightful star animation inspired by Twitter's heart. See blog post for description.

Pros of LikeAnimation

  • Focuses specifically on like/heart animations, providing a polished and targeted solution
  • Includes a demo app showcasing various animation styles and customization options
  • Utilizes vector drawables for smooth scaling and performance

Cons of LikeAnimation

  • Limited to like/heart animations, less versatile than Bubbles for Android
  • Fewer customization options for bubble appearance and behavior
  • Less active development and community engagement

Code Comparison

LikeAnimation:

LikeButtonView likeButtonView = (LikeButtonView) findViewById(R.id.like_button);
likeButtonView.setOnLikeListener(new OnLikeListener() {
    @Override
    public void liked(boolean isLiked) {
        // Handle like action
    }
});

Bubbles for Android:

BubbleLayout bubbleLayout = (BubbleLayout) findViewById(R.id.bubble_layout);
bubbleLayout.addBubble();
bubbleLayout.removeBubble();
bubbleLayout.setOnBubbleClickListener(new BubbleLayout.OnBubbleClickListener() {
    @Override
    public void onBubbleClick(View bubble) {
        // Handle bubble click
    }
});

Both libraries offer easy-to-use APIs, but Bubbles for Android provides more flexibility in terms of bubble creation and management, while LikeAnimation focuses on a specific animation type with pre-defined styles.

explosive dust effect for views

Pros of ExplosionField

  • Offers a unique particle explosion effect for views
  • Simple implementation with minimal setup required
  • Supports custom particle colors and explosion durations

Cons of ExplosionField

  • Limited to explosion effects only, less versatile than Bubbles for Android
  • May not be suitable for all app designs or user interfaces
  • Less actively maintained compared to Bubbles for Android

Code Comparison

ExplosionField:

ExplosionField explosionField = ExplosionField.attach2Window(this);
explosionField.explode(view);

Bubbles for Android:

BubbleLayout bubbleLayout = (BubbleLayout)findViewById(R.id.bubble);
bubbleLayout.setBubbleColor(Color.GREEN);
bubbleLayout.setArrowDirection(BubbleLayout.ArrowDirection.TOP);

ExplosionField focuses on creating particle explosions for views, while Bubbles for Android provides customizable speech bubble layouts. ExplosionField's implementation is simpler, requiring only two lines to create and trigger an explosion effect. Bubbles for Android offers more customization options, such as color and arrow direction, but requires more setup code.

Both libraries enhance Android UI animations, but serve different purposes. ExplosionField is ideal for creating eye-catching dismissal effects, while Bubbles for Android is better suited for creating speech bubble-like layouts for tooltips or chat interfaces.

2,710

Configurable animations based on points

Pros of Grav

  • More customizable particle behavior and animations
  • Supports multiple particle shapes (circles, squares, etc.)
  • Offers a wider range of visual effects and interactions

Cons of Grav

  • Potentially higher performance overhead due to more complex animations
  • Steeper learning curve for implementation and customization
  • May require more fine-tuning to achieve desired visual effects

Code Comparison

Bubbles-for-android:

BubbleLayout bubbleLayout = (BubbleLayout)findViewById(R.id.bubbles);
bubbleLayout.addBubble(R.drawable.bubble_icon);

Grav:

GravView gravView = (GravView) findViewById(R.id.grav);
gravView.setGenerator(new BallGenerator());
gravView.start();

Both libraries offer simple implementation, but Grav provides more options for customization and particle generation. Bubbles-for-android focuses specifically on bubble-like animations, while Grav allows for a broader range of particle types and behaviors.

Grav's flexibility comes at the cost of increased complexity, requiring more setup and configuration to achieve desired effects. Bubbles-for-android, on the other hand, offers a more straightforward approach for creating bubble animations with less customization options.

2,277

A Particle System for standard Android UI: http://plattysoft.github.io/Leonids/

Pros of Leonids

  • More versatile particle system with support for various shapes and behaviors
  • Easier to customize particle animations and trajectories
  • Better documentation and examples provided

Cons of Leonids

  • Slightly more complex setup and configuration
  • May have higher performance overhead for large numbers of particles
  • Less focused on specific bubble-like animations

Code Comparison

Leonids:

new ParticleSystem(this, 80, R.drawable.star_pink, 10000)
    .setSpeedRange(0.1f, 0.25f)
    .setRotationSpeedRange(90, 180)
    .setInitialRotationRange(0, 360)
    .oneShot(anchorView, 100);

Bubbles for Android:

BubbleLayout bubbleView = new BubbleLayout(context);
bubbleView.setColor(Color.BLUE);
bubbleView.setSize(100);
bubbleView.setDuration(5000);
bubbleView.startAnimation();

Both libraries offer simple ways to create animated particles or bubbles, but Leonids provides more granular control over particle behavior, while Bubbles for Android focuses specifically on bubble-like animations with a simpler API.

5,436

A Java library that models spring dynamics and adds real world physics to your app.

Pros of Rebound

  • More versatile, can be used for various animation effects beyond bubbles
  • Better performance due to its spring dynamics simulation
  • Larger community support and more extensive documentation

Cons of Rebound

  • Steeper learning curve compared to Bubbles for Android
  • Requires more setup and configuration for simple animations
  • Not specifically designed for bubble-like animations

Code Comparison

Bubbles for Android:

BubbleLayout bubbleLayout = (BubbleLayout)findViewById(R.id.bubble);
bubbleLayout.setClickable(true);
bubbleLayout.setDraggable(true);

Rebound:

Spring spring = springSystem.createSpring();
spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(40, 3));
spring.addListener(new SimpleSpringListener() {
    @Override
    public void onSpringUpdate(Spring spring) {
        float value = (float) spring.getCurrentValue();
        view.setScaleX(value);
        view.setScaleY(value);
    }
});

Bubbles for Android is more straightforward for creating bubble-like UI elements, while Rebound offers more flexibility for various animation types but requires more setup. Rebound's spring-based system allows for more natural-feeling animations, whereas Bubbles for Android is specifically tailored for bubble UI components with simpler implementation.

Render After Effects animations natively on Android and iOS, Web, and React Native

Pros of Lottie-Android

  • Supports complex animations created in Adobe After Effects
  • Extensive documentation and community support
  • Integrates well with other Airbnb libraries and tools

Cons of Lottie-Android

  • Larger library size compared to Bubbles-for-Android
  • Steeper learning curve for designers and developers
  • May require additional tools or software for creating animations

Code Comparison

Bubbles-for-Android:

BubbleLayout bubbleLayout = (BubbleLayout)findViewById(R.id.bubble);
bubbleLayout.setClickable(true);
bubbleLayout.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        // Handle click event
    }
});

Lottie-Android:

LottieAnimationView animationView = findViewById(R.id.animation_view);
animationView.setAnimation(R.raw.animation);
animationView.setRepeatCount(LottieDrawable.INFINITE);
animationView.playAnimation();

Both libraries offer unique features for Android developers. Bubbles-for-Android provides a simpler solution for creating bubble-like UI elements, while Lottie-Android offers more advanced animation capabilities. The choice between the two depends on the specific requirements of your project and the complexity of animations needed.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Bubbles for Android

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Logo

Latest Version

Download Android Arsenal

How to use

Configuring your project dependencies

Add the library dependency in your build.gradle file.

dependencies {
    ...
    compile 'com.txusballesteros:bubbles:1.2.1'
}

Adding your first Bubble

Compose your Bubble layout, for example using a Xml layout file. Remember that the first view of your Bubble layout has to be a BubbleLayout view.

<com.txusballesteros.bubbles.BubbleLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/avatar"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_gravity="center"
        android:background="@drawable/profile_decorator"
        android:src="@drawable/profile"
        android:scaleType="centerCrop"/>

</com.txusballesteros.bubbles.BubbleLayout>

Create your BubblesManager instance.

private BubblesManager bubblesManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
     bubblesManager = new BubblesManager.Builder(this)
                                        .build();
     bubblesManager.initialize();
    ...
}

@Override
protected void onDestroy() {
    bubblesManager.recycle();
    ...
}

Attach your Bubble to the window.

BubbleLayout bubbleView = (BubbleLayout)LayoutInflater
                                    .from(MainActivity.this).inflate(R.layout.bubble_layout, null);
bubblesManager.addBubble(bubbleView, 60, 20);

Configuring your Bubbles Trash

If you want to have a trash to remove on screen bubbles, you can configure the layout of that.

Define your trash layout Xml.

<ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="20dp"
    android:src="@mipmap/bubble_trash_background"
    android:layout_gravity="bottom|center_horizontal" />

Configure the trash layout with your BubblesManager builder.

private BubblesManager bubblesManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
     bubblesManager = new BubblesManager.Builder(this)
                                        .setTrashLayout(R.layout.bubble_trash_layout)
                                        .build();
     bubblesManager.initialize();
    ...
}

License

Copyright Txus Ballesteros 2015 (@txusballesteros)

This file is part of some open source application.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.

Contact: Txus Ballesteros txus.ballesteros@gmail.com