Giter Club home page Giter Club logo

compoundlayout's Introduction

Android - CompoundLayout

Release Android Arsenal API

It's an Android library that allows you to use Layout as RadioButton or CheckBox. The librarie is Android 14+ compatible. Gradient effect is only Android 21+ compatible.

The demo below is inspired by Cris Samson's gradient hover animation.

demo

Installation

Gradle

repositories {
  	maven { url "https://jitpack.io" }
}
compile 'com.github.jaouan:compoundlayout:1.0.0'

Usage

General

CompoundLayout checked state can be changed programmatically using method myCompoundLayout.setChecked(). Checked state can be retrieved using myCompoundLayout.isChecked(), and can be listened using myCompoundLayout.setOnCheckedChangeListener().

Layout as CheckBox

<com.jaouan.compoundlayout.CompoundLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/a_beautiful_selector"
    app:checked="true" > <!-- Checked or not -->

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lorem ipsum" />

</com.jaouan.compoundlayout.CompoundLayout>

Layout as RadioButton

Basic
<com.jaouan.compoundlayout.RadioLayoutGroup
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:orientation="horizontal"> <!-- Orientation : vertical or horizontal -->

    <com.jaouan.compoundlayout.RadioLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/a_beautiful_selector"
        app:checked="true"> <!-- Checked or not -->

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lorem ipsum" />

    </com.jaouan.compoundlayout.RadioLayout>

    <com.jaouan.compoundlayout.RadioLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/a_beautiful_selector">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lorem ipsum" />

    </com.jaouan.compoundlayout.RadioLayout>

</com.jaouan.compoundlayout.RadioLayoutGroup>
Gradient effect (Android 21+ only)
<com.jaouan.compoundlayout.RadioLayoutGroup
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:orientation="horizontal" > <!-- Orientation : vertical or horizontal -->

    <com.jaouan.compoundlayout.GradientRadioLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:checked="true"
        app:angle="45"
        app:colorA="#AAFFA726"
        app:colorB="#AAEC407A">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lorem ipsum" />

    </com.jaouan.compoundlayout.GradientRadioLayout>

    <!-- Circle clipped -->
    <com.jaouan.compoundlayout.CircleGradientRadioLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:angle="70"
        app:colorA="#AAFFA726"
        app:colorB="#AAEC407A">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lorem ipsum" />

    </com.jaouan.compoundlayout.CircleGradientRadioLayout>

</com.jaouan.compoundlayout.RadioLayoutGroup>

You can use myGradientRadioLayout.setColorA(), myGradientRadioLayout.setColorB() and myGradientRadioLayout.setAngle() to configure the gradient effect programmatically.

License

Apache License Version 2.0

compoundlayout's People

Contributors

jaouan avatar

Watchers

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