Code Monkey home page Code Monkey logo

accordion-view's Introduction

Accordion-View

accordion

Bintray

A Library that fold everything. Just do it, we fold it for you. 5 minutes integration garantee.

Demo app available on google play

Demo

Add it on your project:

Gradle:

compile 'com.xenione.libs:accordion:1.0.1'

Wrap your layout around AccordionView

<?xml version="1.0" encoding="utf-8"?>
<com.xenione.libs.accordion.AccordionView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@id/accordionView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">


            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scaleType="centerCrop"
                android:src="@drawable/pep_botifarra_cover" />

            <TextView
                android:id="@+id/malagenya_lyrics"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:textColor="@android:color/white"
                android:textSize="35dp"
                android:textStyle="bold" />
        </LinearLayout>

    </ScrollView>

</com.xenione.libs.accordion.AccordionView>

Note that: AccordionView has id: accordionView keep it as long as you use it along ViewPager.

  accordionView = (AccordionView) findViewById(R.id.accordionView);
  accordionView.setProgress(percentage);

where percentage goes from 0 (completly closed) to 1 (completly opened)

AccordionView may came along with ViewPager or DrawerLayout.

  • Added into ViewPager

Set your ViewPager and adapter as usual, and don't forget to add into ViewPager AccordionPageTransformer' PageTransformer as it shows below. It is important that accordionView have been identified with android:id="@id/accordionView" according to previous note.

     ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
     PagerAdapter mPagerAdapter = new PagerAdapter(
              getSupportFragmentManager());
      mViewPager.setAdapter(mPagerAdapter);
      mViewPager.setPageTransformer(true, new AccordionPageTransformer());

or

  • Added into DrawerLayout

Set your DrawerLayout as usual, but don't forget to pass through AccordionDrawerListener as it showed below.

      DrawerLayout lateralMenu = (DrawerLayout) findViewById(R.id.drawer_layout);
      accordionView = (AccordionView) findViewById(R.id.accordionView);
      lateralMenu.addDrawerListener(new AccordionDrawerListener(accordionView) {

          @Override
          public void onDrawerSlide(View drawerView, float slideOffset) {
              super.onDrawerSlide(drawerView, slideOffset);
              // add your code here to manage drawerLayout
          }

          @Override
          public void onDrawerOpened(View drawerView) {
              // add your code here to manage drawerLayout
          }

          @Override
          public void onDrawerClosed(View drawerView) {
              // add your code here to manage drawerLayout
          }

          @Override
          public void onDrawerStateChanged(int newState) {
              // add your code here to manage drawerLayout
          }
      });

Note: Here is NOT mandatory to identify your accordionView with 'id:accordionView'

What next?


Try to add AccordionView into a RecyclerView, for this I need extra support, consider either contribute to the project or make a donation.

progress target: 500 € / raised: 223 €

Thanks for all contributors.

  • amounts updated every 24h

Donation


The full money collected here will be destinated to improve Open Source Projects.

paypal

Developed by


Eugeni Josep Senent i Gabriel - @xenione

[email protected]

www.xenione.com

Add me to Linkedin

License


Copyright 2016 Eugeni Josep Senent i Gabriel

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.

accordion-view's People

Contributors

xenione avatar

Watchers

 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.