GithubHelp home page GithubHelp logo

cwftw / achievement_view_android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from szaboa/achievement_view_android

0.0 1.0 0.0 384 KB

A custom view to show achievements on Android

License: MIT License

Java 6.29% Kotlin 93.71%

achievement_view_android's Introduction

AchievementView for Android

A custom view for achievements pop-ups written in Kotlin.

The basic properties can be changed through XML like its size, color, drawable, duration. If this isn't enough then feel free to customize as you wish!

gif

Installation

You can import the achievementview module into your project or just grab it via Gradle,

compile 'com.cdev.android:achievement-view:0.9.1'

Usage

1. Include into your layout

<com.cdev.achievementview.AchievementView
        android:id="@+id/achievement_view"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        custom:collapseStartDelay="3500"
        custom:colorLeft="@color/green_light"
        custom:colorRight="@color/green_dark"
        custom:drawableLeft="@drawable/trophy"/>

2. Get a reference and call show

Java

AchievementView achievementView = (AchievementView) findViewById(R.id.achievement_view);

// show the achievement with a single line
achievementView.show("Single line text");

// show the achievement with two lines
achievementView.show("First line", "Second line");

Kotlin

val achievementView = findViewById(R.id.achievement_view) as AchievementView

// show the achievement with a single line
achievementView.show("Single line text")

// show the achievement with two lines
achievementView.show("First line", "Second line")

3. Clear animation

You need to call clearAnimation() to cancel any ongoing animation when you intend to, also consider to call it in onPause() or onStop().

Customize

The following attributes can be changed,

custom:rightPartWidth="250dp"                   // default 300 dp
custom:revealDuration="300"                     // default 500 ms
custom:concealStartDelay="1000"                 // default 500 ms
custom:expandDuration="300"                     // default 500 ms
custom:collapseStartDelay="3500"                // default 1500 ms
custom:colorLeft="@color/green_light"           // default #607D8B
custom:colorRight="@color/green_dark"           // default #455A64
custom:drawableLeft="@drawable/trophy"          // default not set
custom:firstLine="First line"                   // default not set
custom:secondLine="Second line"                 // default not set
custom:textColorFirstLine="@color/colorPrimary" // default white
custom:textColorSecondLine="@color/colorAccent" // default white
custom:textSizeFirstLine="10sp"                 // default not set
custom:textSizeSecondLine="8sp"                 // default not set

If you doesn't specify an attribute, then a default value will be set.

License

This project is licensed under the MIT License - see the License.md file for details

achievement_view_android's People

Contributors

szaboa avatar

Watchers

James Cloos 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.