Giter Club home page Giter Club logo

collapselayout's Introduction

CollapseLayout

CollapseLayout can collapse/expand layout with smooth animation.

Here is a gif showing the effect:

demo gif

How to use

<com.example.collapselayout.CollapseLayout
	android:id="@+id/el"
	android:layout_width="match_parent"
	android:layout_height="wrap_content" >
	
	<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        
        .........
        
	</LinearLayout>
	
</com.example.collapselayout.CollapseLayout>
public void showEffect(View v) {
	int modeId = modeGroup.getCheckedRadioButtonId();
	switch (modeId) {
	case R.id.fixedTop:
		el.setCollapseMode(Mode.FIXED_START);
		break;
	case R.id.fixedBottom:
		el.setCollapseMode(Mode.FIXED_END);
		break;
	}
	
	int interpolatorId = interpolatorGroup.getCheckedRadioButtonId();
	switch (interpolatorId) {
	case R.id.linear:
		el.setInterpolator(linearInterpolator);
		break;
	case R.id.bounce:
		el.setInterpolator(bounceInterpolator);
		break;
	case R.id.accelerate:
		el.setInterpolator(accelerateDecelerateInterpolator);
		break;
	}
	
	int orientationId = orientationGroup.getCheckedRadioButtonId();
	switch (orientationId) {
	case R.id.vertical:
		el.setCollapseOrientation(Orientation.VERTICAL);
		break;
	case R.id.horizontal:
		el.setCollapseOrientation(Orientation.HORIZONTAL);
		break;
	}
	
	int state = el.getState();
	switch (state) {
	case CollapseLayout.STATE_OPEN:
		el.close();
		break;
	case CollapseLayout.STATE_CLOSE:
		el.open();
		break;
	}
}
<declare-styleable name="CollapseLayout">
	<attr name="collapseOrientation">
	    <enum name="vertical" value="0" />
	    <enum name="horizontal" value="1" />
	</attr>
	<attr name="collapseMode">
	    <enum name="fixed_end" value="0"/>
	    <enum name="fixed_start" value="1"/>
	</attr>
	<attr name="initialCollapseState">
	    <enum name="open" value="0"/>
	    <enum name="close" value="1"/>
	</attr>
	<attr name="collapseDuration" format="integer"/>
</declare-styleable>

collapselayout's People

Contributors

ubdc avatar uuubd 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.