:ribbon: The simple way to implement a beautiful ribbon with the shimmering on Android.

Overview

AndroidRibbon

License API Codacy Build Status Javadoc Profile

🎀 The simple way to implement a beautiful ribbon with the shimmering on Android. 中文語


Download

Maven Central Jitpack

Gradle

Add below codes to your root build.gradle file (not your module build.gradle file).

allprojects {
    repositories {
        mavenCentral()
    }
}

And add a dependency code to your module's build.gradle file.

dependencies {  
    implementation "com.github.skydoves:androidribbon:1.0.3"
}

Usage

Add following XML namespace inside your XML layout file.

xmlns:app="http://schemas.android.com/apk/res-auto"

RibbonView in layout

<com.skydoves.androidribbon.RibbonView
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:text="skydoves"
     android:textColor="@android:color/white"
     app:ribbon_rotation="-45" // set rotation
     app:ribbon_background_color="@color/colorPrimary" // set background color
     app:ribbon_ribbonRadius="4dp" // set radius
     app:ribbon_drawable="@drawable/ribbon03" // set drawable, not background color
     app:ribbon_padding_top="4dp"
     app:ribbon_padding_bottom="8dp"/>

create using Builder

This is how to create RibbonView's instance using RibbonView.Builder class.

new RibbonView.Builder(context)
      .setText("Android-Ribbon")
      .setTextColor(Color.WHITE)
      .setTextSize(13f)
      .setRibbonRotation(-45)
      .setRibbonBackgroundColor(ContextCompat.getColor(context, R.color.bright_lavender))
      .setRibbonDrawable(ContextCompat.getDrawable(context, R.drawable.ribbon03))
      .build();

create using kotlin dsl

This is how to create RibbonView's instance using kotlin dsl.

val ribbonView = ribbonView(this) {
      setText("Android-Ribbon")
      setTextColor(Color.WHITE)
      setTextSize(13f)
      setTextStyle(Typeface.BOLD)
      setRibbonRotation(-45)
      setRibbonDrawableResource(R.drawable.ribbon02)
    }

ShimmerRibbonView

ShimmerRibbonView lets you implement shimmer animation easily.

ShimmerRibbonView in layout

<com.skydoves.androidribbon.ShimmerRibbonView
      android:layout_width="130dp"
      android:layout_height="wrap_content"
      android:alpha="0.8"
      app:shimmer_base_alpha="1.0"
      app:shimmer_highlight_alpha="0.5"
      app:shimmer_ribbon_text="Android-Ribbon"
      app:shimmer_ribbon_textColor="@android:color/white"
      app:shimmer_ribbon_textStyle="bold"
      app:shimmer_ribbon_padding_top="3dp"
      app:shimmer_ribbon_padding_bottom="3dp"
      app:shimmer_ribbon_rotation="-45"
      app:shimmer_ribbon_background_color="@color/colorPrimary"/>

create using Builder

This is how to create ShimmerRibbonView's instance using ShimmerRibbonView.Builder class.

new ShimmerRibbonView.Builder(context)
      .setRibbonView(ribbonView)
      .setShimmer(shimmer)
      .build();

create using kotlin dsl

This is how to create ShimmerRibbonView's instance using kotlin dsl.

val shimmerRibbonView = shimmerRibbonView(context) {
      ribbon = ribbonView(context) {
          text = "Android-Ribbon"
          textColor = Color.WHITE
          textSize = 13f
          textStyle = Typeface.BOLD
          ribbonRotation = -45
          ribbonDrawable = ContextCompat.getDrawable(context, R.drawable.ribbon02)
      }
      shimmer = alphaShimmer {
          setBaseAlpha(1.0f)
          setHighlightAlpha(0.5f)
       }
    }

Shimmer

This library using shimmer-android by Facebook.
Here are the detail shimmer-instruction about shimmer or you can reference below examples.

create using Builder

This is how to create Shimmer's instance using Shimmer.Builder class.

new Shimmer.AlphaHighlightBuilder()
      .setBaseAlpha(1.0f)
      .setHighlightAlpha(0.5f)
      .setRepeatDelay(1000)
      .setDuration(1000)
      .setDirection(Shimmer.Direction.RIGHT_TO_LEFT)
      .build();

create using kotlin dsl

This is how to create Shimmer's instance using kotlin dsl.

val shimmer_alpha = alphaShimmer {
      setBaseAlpha(1.0f)
      setHighlightAlpha(0.5f)
}
val shimmer_color = colorShimmer {
      setBaseAlpha(1.0f)
      setHighlightAlpha(0.5f)
      setBaseColor(ContextCompat.getColor(context, R.color.colorPrimary))
      setHighlightColor(ContextCompat.getColor(context, R.color.colorPrimaryDark))
}

RibbonLayout

RibbonLayout lets RibbonViews overlap with other child views.

RibbonLayout in layout

<com.skydoves.androidribbon.RibbonLayout
      android:id="@+id/ribbonLayout01"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      app:ribbonLayout_header_align="left"
      app:ribbonLayout_bottom_align="center">

     <ImageView
          android:layout_width="match_parent"
          android:layout_height="180dp"
          android:src="@drawable/background02"
          android:scaleType="fitXY"/>
</com.skydoves.androidribbon.RibbonLayout>

And should set ribbonHeader or ribbonBottom using RibbonView or ShimmerRibbonView instance.

ribbonLayout.setRibbonHeader(ribbon_header);
ribbonLayout.setRibbonBottomAlign(Gravity.LEFT);
ribbonLayout.setRibbonBottom(ribbon_bottom);
ribbonLayout.setRibbonBottomAlign(Gravity.RIGHT);

RibbonRecyclerView

RibbonRecyclerView lets you implement RecyclerView has RibbonView items easily.

RibbonRecyclerView in layout

<com.skydoves.androidribbon.RibbonRecyclerView
      android:id="@+id/ribbonRecyclerView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="15dp"
      app:ribbon_recycler_space="3dp"
      app:ribbon_recycler_orientation="horizontal"/>

Add or remove RibbonView items.

recyclerView.addRibbon(ribbonView);
recyclerView.addRibbon(2, ribbonView);
recyclerView.addRibbonList(ribbonViewList);
recyclerView.removeRibbon(ribbonView);
recyclerView.removeRibbon(2);
recyclerView.clear();

RibbonView Attributes

Attributes Type Default Description
ribbonBackgroundColor Color #e254ff sets ribbon background using color.
ribbonRadius Float 10f sets ribbon corner's radius. It's only active using with ribbonBackgroundColor.
ribbonDrawable Drawable null sets ribbon background using drawable. ribbonBackgroundColor and ribbonRadius will be ignored.
ribbonRotation Int 0 sets ribbon rotation. Only between 1 to 90 or -90 to -1 degree.
paddingLeft Float 8f sets left padding of the text.
paddingTop Float 4f sets top padding of the text.
paddingRight Float 8f sets right padding of the text.
paddingBottom Float 4f sets bottom padding of the text.
text String "" sets text. It is same as android:text attribute.
textColor Color Color.WHITE sets text color. It is same as android:textColor attribute.
textSize Float 12f sets text size. It is same as android:textSize attribute.
textStyle Int Typeface.NORMAL sets text style. It is same as android:textStyle attribute.

ShimmerRibbonView Attributes

Attributes Type Default Description
ribbon RibbonView RibbonView(context) sets RibbonView on the frame.
shimmer Shimmer AlphaHighlightBuilder(context).build() sets Shimmer on the frame.

ShimmerLayout Attributes

Attributes Type Default Description
ribbonHeader RibbonView RibbonView(context) sets header RibbonView on the frame.
ribbonBottom RibbonView RibbonView(context) sets bottom RibbonView on the frame.
ribbonHeaderAlign Gravity Gravity.START sets an align of the header ribbon.
ribbonBottomAlign Gravity Gravity.CENTER sets an align of the bottom ribbon.

Find this library useful? ❤️

Support it by joining stargazers for this repository.
And follow me for my next creations! 🤩

License

Copyright 2019 skydoves

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.
Comments
  • RibbonView changes x/y position when being recreated

    RibbonView changes x/y position when being recreated

    Please complete the following information:

    • 1.0.2
    • Likely all, but tested on an Emulator with Android 11

    Describe the Bug:

    When using RibbonView in e.g. a RecyclerView, clicking on an item in the RecyclerView, and then returning to the RecyclerView after a few times the position of the ribbon will change.

    The likely reason for this is a missing check in onLayout(changed: Boolean, ...) whether the layout actually did change. Only then the rotation code should be applied which also changes x/y values of the View.

    I'll provide a PR with a fix.

    Expected Behavior:

    Postition of the ribbon always stays stable.

    opened by ubuntudroid 2
  • ShimmerRibbonView moving when Keyboard opens

    ShimmerRibbonView moving when Keyboard opens

    • Library-Version [1.0.2]

    Describe the Bug:

    My Layout having CoordinatorLayout -> (In Top) AppBarLayout-> CollapsingToolbarLayout-> MaterialToolbar-> ConstraintLayout-> AppCompatEditText and RecyclerView inside CoordinatorLayout. Used ShimmerRibbonView in the RecyclerView Item. Whenever the keyboard opens for AppCompatEditText, the ShimmerRibbonView is moves toward left

    Expected Behavior:

    ShimmerRibbonView should not move.

    opened by mahendravijay 2
  • RibbonView DrawableTint is not Working

    RibbonView DrawableTint is not Working

    Hi sir, I am using your library and its awesome. Currently I am facing issue with RibbonView Drawable tint is not working with SVG.

    <com.skydoves.androidribbon.RibbonView android:id="@+id/rbView" android:layout_width="wrap_content" android:layout_height="@dimen/_33sdp" android:text="Active" android:textColor="@color/white" android:textSize="@dimen/_10ssp" app:ribbon_rotation="40" android:fontFamily="@font/montserrat_medium" app:ribbon_drawable="@drawable/ic_ban_horizontal" app:ribbon_ribbonRadius="@dimen/_4sdp" app:drawableTint="@color/colorBlue" />

            here us the code that I am using.
    
    opened by waleedkalyar 1
  • RecyclerView ShimmerRibbonView Auto Resize

    RecyclerView ShimmerRibbonView Auto Resize

    Hi, I have used ShimmerRibbonView in recyclerview and the parent is constraint layout. In UI Editor and app deployed, view working good. But after navigating to a new Activity by clicking on the card where ShimmerRibbonView is placed, returning back to the current activity view automatically positions itself down. If tried three times, each time view goes down to its height. I tried to fix it by placing it in a container with some width and height even though, view appears to be resizing itself. Adapter was not refreshed at that time onResume().

    opened by perusudroid 1
  • #4 Fix RibbonView changing position even if layout didn't change

    #4 Fix RibbonView changing position even if layout didn't change

    Fixes #4 by always checking for actual changes in layout before applying rotation and positional updates.

    Types of changes

    What types of changes does your code introduce?

    • [x] Bugfix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
    opened by ubuntudroid 0
Releases(1.0.4)
Owner
Jaewoong Eum
Android software engineer. Digital Nomad. Open Source Contributor. ❤️ Love coffee, music, magic tricks and writing poems. Coffee Driven Development.
Jaewoong Eum
An image loading and caching library for Android focused on smooth scrolling

Glide | View Glide's documentation | 简体中文文档 | Report an issue with Glide Glide is a fast and efficient open source media management and image loading

Bump Technologies 33.2k Jan 7, 2023
Android Asynchronous Networking and Image Loading

Android Asynchronous Networking and Image Loading Download Maven Git Features Kotlin coroutine/suspend support Asynchronously download: Images into Im

Koushik Dutta 6.3k Dec 27, 2022
A powerful image downloading and caching library for Android

Picasso A powerful image downloading and caching library for Android For more information please see the website Download Download the latest AAR from

Square 18.4k Jan 6, 2023
Powerful and flexible library for loading, caching and displaying images on Android.

Universal Image Loader The great ancestor of modern image-loading libraries :) UIL aims to provide a powerful, flexible and highly customizable instru

Sergey Tarasevich 16.8k Jan 8, 2023
An Android library for managing images and the memory they use.

Fresco Fresco is a powerful system for displaying images in Android applications. Fresco takes care of image loading and display, so you don't have to

Facebook 16.9k Jan 8, 2023
Image loading for Android backed by Kotlin Coroutines.

An image loading library for Android backed by Kotlin Coroutines. Coil is: Fast: Coil performs a number of optimizations including memory and disk cac

Coil 8.8k Jan 8, 2023
Adds touch functionality to Android ImageView.

TouchImageView for Android Capabilities TouchImageView extends ImageView and supports all of ImageView’s functionality. In addition, TouchImageView ad

Michael Ortiz 2.6k Jan 1, 2023
A circular ImageView for Android

CircleImageView A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniq

Henning Dodenhof 14.4k Jan 5, 2023
Custom shaped android imageview components

Shape Image View Provides a set of custom shaped android imageview components, and a framework to define more shapes. Implements both shader and bitma

Siyamed SINIR 2.6k Jan 8, 2023
Android ImageView that handles animated GIF images

GifImageView Android ImageView that handles Animated GIF images Usage In your build.gradle file: dependencies { compile 'com.felipecsl:gifimageview:

Felipe Lima 1.1k Dec 27, 2022
Android ImageView that supports different radii on each corner.

SelectableRoundedImageView Note that this project is no longer maintained. Android ImageView that supports different radii on each corner. It also sup

Joonho Kim 1.1k Nov 25, 2022
An Android view for displaying repeated continuous side scrolling images. This can be used to create a parallax animation effect.

Scrolling Image View An Android view for displaying repeated continuous side scrolling images. This can be used to create a parallax animation effect.

Q42 1.8k Dec 27, 2022
Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.

ChiliPhotoPicker Made with ❤️ by Chili Labs. Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it w

Chili Labs 394 Jan 2, 2023
An Android transformation library providing a variety of image transformations for Glide.

Glide Transformations An Android transformation library providing a variety of image transformations for Glide. Please feel free to use this. Are you

Daichi Furiya 9.7k Dec 30, 2022
An android image compression library.

Compressor Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller

Zetra 6.7k Jan 9, 2023
An Android transformation library providing a variety of image transformations for Picasso

Picasso Transformations An Android transformation library providing a variety of image transformations for Picasso. Please feel free to use this. Are

Daichi Furiya 1.7k Jan 5, 2023
Media Picker is an Android Libary that lets you to select multiple images or video

Media Picker Please let me know if your application go to production via this link Media Picker is an Android Libary that lets you to select multiple

Abdullah Alhazmy 264 Nov 10, 2022
Library to handle asynchronous image loading on Android.

WebImageLoader WebImageLoader is a library designed to take to hassle out of handling images on the web. It has the following features: Images are dow

Alexander Blom 102 Dec 22, 2022
Render 3D content in your Augmented Reality Android apps

Use the RealityCore SDK to implement high-performance 3D simulation and rendering.

Thomas Gorisse 25 Jun 16, 2022