It's an Android library that allows you to use Layout as RadioButton or CheckBox.

Overview

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.1'

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

You might also like...
Share Layout Android Library
Share Layout Android Library

Share any layout screenshot including any string of any Android App to any app via Intent .

VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.
VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.

Vorolay VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions. [Voronoi diagram] (https://en.wikip

An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu

ResideLayout An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu. Can be used on Android 1.6(I haven't try it.)

Android layout that simulates physics using JBox2D
Android layout that simulates physics using JBox2D

PhysicsLayout Android layout that simulates physics using JBox2D. Simply add views, enable physics, and watch them fall! See it in action with the sam

An Android demo of a foldable layout implementation. Engineered by Vincent Brison.
An Android demo of a foldable layout implementation. Engineered by Vincent Brison.

Foldable Layout This code is a showcase of a foldable animation I created for Worldline. The code is fully written with java APIs from the Android SDK

A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc.  really a practical RefreshLayout!
A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!

RecyclerRefreshLayout English | 中文版 RecyclerRefreshLayout based on the {@link android.support.v4.widget.SwipeRefreshLayout} The RecyclerRefreshLayout

Easy, flexible and powerful Swipe Layout for Android
Easy, flexible and powerful Swipe Layout for Android

SwipeRevealLayout A layout that you can swipe/slide to show another layout. Demo Overview Drag mode Drag mode normal: Drag mode same_level: Features F

[UNMAINTAINED]: AndroidMosaicLayout is android layout to display group of views as grid consists of different asymmetric patterns (90 different patterns).
[UNMAINTAINED]: AndroidMosaicLayout is android layout to display group of views as grid consists of different asymmetric patterns (90 different patterns).

AndroidMosaicLayout AndroidMosaicLayout is android layout to display group of views in more that 90 different patterns. What is AndroidMosaicLayout? I

Scalable Layout For Android
Scalable Layout For Android

ScalableLayout for Android. Class: com.ssomai.android.scalablelayout.ScalableLayout 한글버전 README.md: https://github.com/ssomai/ScalableLayout/blob/mast

Comments
  • Error inflating class com.jaouan.compoundlayout.CircleGradientRadioLayout?

    Error inflating class com.jaouan.compoundlayout.CircleGradientRadioLayout?

    23816/com.endroidteam.muhabirce E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.endroidteam.muhabirce, PID: 23816
                                                                               java.lang.RuntimeException: Unable to start activity ComponentInfo{com.endroidteam.muhabirce/com.endroidteam.muhabirce.activities.DevActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class com.jaouan.compoundlayout.CircleGradientRadioLayout
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2318)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
                                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:139)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                   at android.os.Looper.loop(Looper.java:149)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5257)
                                                                                   at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                   at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
                                                                                   at dalvik.system.NativeStart.main(Native Method)
                                                                                Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class com.jaouan.compoundlayout.CircleGradientRadioLayout
                                                                                   at android.view.LayoutInflater.createView(LayoutInflater.java:620)
                                                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                                                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                                   at com.endroidteam.muhabirce.activities.DevActivity.onCreate(DevActivity.java:22)
                                                                                   at android.app.Activity.performCreate(Activity.java:5411)
                                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396) 
                                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:139) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:149) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5257) 
                                                                                   at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                   at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
                                                                                   at dalvik.system.NativeStart.main(Native Method) 
                                                                                Caused by: java.lang.reflect.InvocationTargetException
                                                                                   at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                                   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                                                                                   at android.view.LayoutInflater.createView(LayoutInflater.java:594)
                                                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                   at com.endroidteam.muhabirce.activities.DevActivity.onCreate(DevActivity.java:22) 
                                                                                   at android.app.Activity.performCreate(Activity.java:5411) 
                                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270) 
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396) 
                                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:139) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:149) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5257) 
                                                                                   at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                   at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
                                                                                   at dalvik.system.NativeStart.main(Native Method) 
                                                                                Caused by: java.lang.NoSuchMethodError: android.widget.FrameLayout.<init>
                                                                                   at com.jaouan.compoundlayout.CompoundLayout.<init>(CompoundLayout.java:62)
                                                                                   at com.jaouan.compoundlayout.RadioLayout.<init>(RadioLayout.java:24)
                                                                                   at com.jaouan.compoundlayout.GradientRadioLayout.<init>(GradientRadioLayout.java:65)
                                                                                   at com.jaouan.compoundlayout.CircleGradientRadioLayout.<init>(CircleGradientRadioLayout.java:34)
                                                                                   at com.jaouan.compoundlayout.CircleGradientRadioLayout.<init>(CircleGradientRadioLayout.java:30)
                                                                                   at com.jaouan.compoundlayout.CircleGradientRadioLayout.<init>(CircleGradientRadioLayout.java:26)
                                                                                   at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                                   at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
                                                                                   at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
                                                                                   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
                                                                                   at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
                                                                                   at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
                                                                                   at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                                   at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                   at com.endroidteam.muhabirce.activities.DevActivity.onCreate(DevActivity.java:22) 
                                                                                   at android.app.Activity.performCreate(Activity.java:5411) 
                                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270) 
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396) 
                                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:139) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:149) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5257) 
                                                                                   at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                   at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
                                                                                   at dalvik.system.NativeStart.main(Native Method) 
    
    bug 
    opened by nuhkoca 1
Releases(1.0.1)
Owner
A boy has no bio.
null
Android implementation of FlowLayout. Layout arranges its children in multiple rows depending on their width.

FlowLayout FlowLayout is an opensource Android library that alows developers to easily integrate flow layout into their app. FlowLayout is an layout t

Blaž Šolar 754 Dec 15, 2022
Android - A layout that arranges its children in relation to a background image

ImageLayout A layout that arranges its children in relation to a background image. The layout of each child is specified in image coordinates (pixels)

Manuel Peinado Gallego 419 Nov 14, 2022
Linear layout, that wrap its content to the next line if there is no space in the current line.

Android flow layout Introduction Extended linear layout that wrap its content when there is no place in the current line. [] (https://travis-ci.org/Ap

Artem.Votincev 2k Jan 5, 2023
ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way

ConstraintLayout is a layout manager for Android which allows you to position and size widgets in a flexible way. It's available for both the Android view system and Jetpack Compose.

Android Jetpack 970 Jan 6, 2023
GoolgePlusLayout is a custom layout that plays animation on the children views while scrolling as the layout in the Google Plus (android) main page

Google Plus Layout Google Plus Layout is a custom layout that support playing animation on child view(s) in a serialize manner like the the main

Ahmed Nammari 224 Nov 25, 2022
Responsive Layout Gird Configuration using Compose. An adaptive layout

ResponsiveGrid Responsive Grid is most followed layout system by the designer as it adapts to screen size and orientation, ensuring consistency across

null 4 Apr 12, 2022
A 3D Layout for Android,When you use it warp other view,it can became a 3D view,一秒让你的view拥有3D效果!

ThreeDLayout A 3D Layout,When you use it warp other view,it can became a 3D view 中文文档 preview USAGE 1.compile library allprojects { repositories {

androidwing 490 Oct 27, 2022
This assignment gives you basically a post list and its detail with comments.🚀

Android Assignment ?? Description This assignment gives you basically a post list and its detail with comments. ?? Features Users can see random post

Okan AYDIN 31 Dec 20, 2022
A library that easily allows you to mask layouts/viewgroups

Maskable Layout Overview ======================= The Maskable Layout is a simple framelayout that allows you to easily mask views and viewgroups. You

Christophe Smet 654 Dec 2, 2022
A very simple arc layout library for Android

ArcLayout A very simple arc layout library for Android. Try out the sample application on the Play Store. Usage (For a working implementation of this

ogaclejapan 1.4k Dec 26, 2022