Giter Site home page Giter Site logo

strikedimageview's Introduction

StrikedImageView

Animate a strike over any image to indicate on/off states. As seen in the Material Guidelines.

StrikedImageView

Platform API

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.DamonBaker:StrikedImageView:1.0.0'
}

Usage

Set base drawable like you would a regular ImageView. It is recommended that you also set the android:tint attribute so the view knows what color to tint the strike.

<xyz.damonbaker.strikedimageview.StrikedImageView
    android:id="@+id/striked_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:tint="#FFC107"
    app:srcCompat="@drawable/ic_camera_black_24dp"
    app:striked="false" />
val strikedImage: StrikedImageView = findViewById(R.id.striked_image)
strikedImage.setImageDrawable(drawable)

Set isStriked to apply the animation.

strikedImage.isStriked = true

Limitations

  • StrikedImageView works best with vector drawables, if you are not using a vector drawable as the image source then the strikeColor attribute must be set if you want the strike color to match the color of the drawable.
  • A tint should be set on the StrikedImageView so the view knows what color to tint the strike, otherwise you can set strikeColor manually.
  • In order to simulate the clip-through effect of the strike, the view hierarchy is traversed until the first parent with a ColorDrawable is found. This color will be used as the strikeBackgroundColor.
    • If the parent's background is not an instance of ColorDrawable (i.e. a drawable instead of a color), then the strikeBackgroundColor attribute must be manually set.

strikedimageview's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.