Code Monkey home page Code Monkey logo

bubblegum's Introduction

BubbleGum - Sweet Android Gradients

Download

BubbleGum was designed to quickly apply gradients into different UI elements of an android app. The overhead and performance impact is minimal, as BubbleGum is based on Android drawables.

Features

  • Apply gradient to a view with an animation effect or transition between 2 gradients.
  • Created an animated view with a set of gradients that interchange at the specified amount of time.
  • It applies a vignetting effect over the gradient to enhance the view. (will become optional in the future)
  • Control gradient angle
  • Apply the gradient colors at custom positions. If custom positions are not specified, they will be distributed equally.

Demo

IMAGE ALT TEXT HERE

Or give it a try with the sample app: https://play.google.com/store/apps/details?id=com.hold1.bubblegum

Installation

Add the following line in your build.gradle file

implementation 'com.hold1:bubblegum:0.0.1'

Usage

BubbleGum can be used in 3 ways, depending of your needs:

1. Embed a BubbleView into your layout and use it as a canvas for displaying other views on top of it. This is the easiest way if you are trying to achieve immediate results from your xml layout.
    <com.hold1.bubblegum.BubbleView
        android:id="@+id/headerBackground"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:bbStartColor="@color/demoStartColor"
        app:bbEndColor="@color/demoEndColor"
        app:bbAngle="45"/>

You can always change the applied gradient of a BubbleView programatically. Please refer to SlideFragment in Demo app.

2. Create an GradientDrawable and use it.
    val g1 = Gradient(intArrayOf(Color.RED, Color.GREEN))
    val g2 = Gradient(intArrayOf(Color.DKGRAY, Color.BLUE))
    val g3 = Gradient(intArrayOf(Color.CYAN, Color.MAGENTA))
    
    val animation = GradientDrawable(arrayOf(g2, g1, g3))
    baseView.background = animation
        
    animation.start()
3. Use the BubbleBuilder class to apply a gradient as a background to an existing view
    BubbleBuilder()
            .withStartColor(Color.RED)
            .withEndColor(Color.BLUE)
            .withAngle(35)
            .intoView(exampleView)

bubblegum's People

Contributors

crysis21 avatar

Watchers

Michael jentsch avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.