Code Monkey home page Code Monkey logo

cameleonlayout's Introduction

CameleonLayout

License Build Status
A library that let you implement double-layer-layout changing with slide animation.

gif1 gif0

Including in your project

build.gradle

dependencies {
  implementation "com.github.skydoves:cameleonlayout:1.0.0"
}

Usage

Could be used just like using normal Layout.

cameleonLayout.setSecondLayout(R.layout.layout_second) // set the second layout
cameleonLayout.drawSecondLayout() // start drawing second layout

FilledStatusListener

Invoked when CameleonLayout's status is changed.

override fun onFilledStatusChanged(status: FilledStatus) {
   when(status) {
      is FilledStatus.UnFilled ->  Toast.makeText(this, "unFilled", Toast.LENGTH_SHORT).show()
      is FilledStatus.Loading ->  Toast.makeText(this, "Loading", Toast.LENGTH_SHORT).show()
      is FilledStatus.Filled -> {
          cameleonLayout.eraseSecondLayout() // erase the second layout gradually when be Filled.
          Toast.makeText(this, "Filled", Toast.LENGTH_SHORT).show()
       }
   }
}

onClickListener

CameleonLayout onClickListener. It provides FilledStatus.

override fun onClick(status: FilledStatus) {
    when(status) {
       is FilledStatus.UnFilled -> cameleonLayout.drawSecondLayout()
       is FilledStatus.Loading ->  Toast.makeText(this, "clicked onLoading", Toast.LENGTH_SHORT).show()
       is FilledStatus.Filled -> Toast.makeText(this, "clicked onFilled", Toast.LENGTH_SHORT).show()
   }
}

XML layout

<?xml version="1.0" encoding="utf-8"?>
<com.skydoves.cameleonlayout.CameleonLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cameleonLayout1"
    android:layout_width="140dp"
    android:layout_height="110dp"
    android:background="@drawable/gradient_purple"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="15dp"
    app:secondLayout="@layout/layout_thumbnail1"
    app:maxProgress="100"
    app:density="2"
    app:duration="1000"
    app:delay="2000"
    app:autoUnFill="true"
    app:drawOnBack="false">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/black"
            android:alpha="0.6"/>

        <TextView
            android:id="@+id/item_episode_coin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/white"
            android:text="glance"
            android:layout_centerInParent="true"
            android:textStyle="bold"
            android:textSize="25sp"/>
    </RelativeLayout>
</com.skydoves.cameleonlayout.CameleonLayout>

Methods

Methods Return Description
setSecondLayout(int layout) void set the second layout.
setSecondLayout(View view) void set the second layout.
updateProgress(Float progress) void update progress manually.
drawSecondLayout() void start drawing the second layout gradually.
eraseSecondLayout() void erase the second layout gradually.

Attributes

Attributes Default Description
secondLayout null set the second layout.
maxProgress 100 set the max progress.
density 1 decide the filling unit.
duration 3000(millisec) decide filling & unfilling duration.
delay 2000(millisec) delaying time after being filled. autoUnFill should be 'true'.
autoUnFill true invoke eraseSecondLayout automatically when Filled and delay.
drawOnBack false draw the second layout behind the CameleonLayout's children.

License

Copyright 2018 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.

cameleonlayout's People

Contributors

skydoves 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.