All Projects → SysdataSpA → Fancyaccordionview

SysdataSpA / Fancyaccordionview

Licence: apache-2.0
An Android fancy accordion view

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Fancyaccordionview

Toothyprogress
A polyline determinated ProgressBar written in Kotlin
Stars: ✭ 56 (-12.5%)
Mutual labels:  view, widget
Pure Css3 Animated Border
Pure CSS3 animated border for all html element.
Stars: ✭ 63 (-1.56%)
Mutual labels:  ui-components, widget
simple-analog-clock
Simple clock view for displaying uh...time?
Stars: ✭ 24 (-62.5%)
Mutual labels:  widget, view
a11yAccordion
An accessible and easy to use Accordeon widget.
Stars: ✭ 37 (-42.19%)
Mutual labels:  widget, accordion
Flutter Settings Ui
Create native settings for Flutter app in a minutes.
Stars: ✭ 363 (+467.19%)
Mutual labels:  ui-components, widget
Accordion
Silky-smooth accordion widgets with no external dependencies.
Stars: ✭ 32 (-50%)
Mutual labels:  widget, accordion
a11y-accordion-tabs
A script for an accessible accordion tabs component
Stars: ✭ 50 (-21.87%)
Mutual labels:  accordion, ui-components
Overflow Pager Indicator
Simple paging indicator widget with pager dataset ovewflow effect à la Instagram behavior
Stars: ✭ 136 (+112.5%)
Mutual labels:  view, widget
Supertextview
Hi,Developer,Welcome to use SuperTextView !
Stars: ✭ 3,170 (+4853.13%)
Mutual labels:  view, widget
Colorpicker
jQuery UI widget for color picking (similar to the one in Microsoft Office 2010).
Stars: ✭ 271 (+323.44%)
Mutual labels:  ui-components, widget
AndroidUiKit
uikit widget common baseview Adapter faster develop
Stars: ✭ 48 (-25%)
Mutual labels:  widget, view
Iconswitch
🍭 Custom Android Switch widget
Stars: ✭ 874 (+1265.63%)
Mutual labels:  view, widget
View Effects
Apply custom effects on view backgrounds
Stars: ✭ 176 (+175%)
Mutual labels:  view, ui-components
CheckableTextView
A simple and flexible Checked TextView or Checkable TextView
Stars: ✭ 108 (+68.75%)
Mutual labels:  widget, view
Enviews
🌟A cool dynamic view library
Stars: ✭ 1,771 (+2667.19%)
Mutual labels:  view, ui-components
chatKit
Open Source React Chat Widget. Ready for use and can be connected to any backend like Chatbot/NLP/Live Chat engine or messenger.
Stars: ✭ 42 (-34.37%)
Mutual labels:  widget, ui-components
Ka Table
Lightweight MIT React Table component for both TS and JS with Sorting, Filtering, Grouping, Virtualization, Editing and many more
Stars: ✭ 117 (+82.81%)
Mutual labels:  ui-components, widget
Flutterweekview
Displays a highly customizable week view (or day view) which is able to display events, to be scrolled, to be zoomed-in & out and a lot more !
Stars: ✭ 130 (+103.13%)
Mutual labels:  view, widget
flutter json view
📄 Displaying json models in a Flutter widget
Stars: ✭ 28 (-56.25%)
Mutual labels:  widget, ui-components
Flutter badges
A flutter package for creating badges.
Stars: ✭ 391 (+510.94%)
Mutual labels:  ui-components, widget

FancyAccordionView

An Android fancy accordion view,

1. Demo

To run the example demo, clone the repo, import the project in Android Studio and run the app.

demo

2. What is FancyAccordionView?

FancyAccordionView is a custom view that can be used for showing a list of items. It extends RecyclerView and offers the following features:

  • allows you to expand and collapse each item
  • allows custom layout for extended/collapsed item
  • callback for extended/collapsed item click
  • scroll up the clicked item
  • multiple layout for extended/collapsed item

3. How to use it?

To use the FancyAccordionView in your project follow this steps.

3.1 Add the library as a dependency

  1. in Project level build.gradle add this repository
   maven { url  'https://dl.bintray.com/sysdata/maven' }
  1. in your App level build.gradle add this dependency
    implementation 'it.sysdata.mobile:fancyaccordionview:1.0.1'

3.2 Add FancyAccordionView to your layout

Open your layout file and add the FancyAccordionView:

<com.sysdata.widget.accordion.FancyAccordionView
        android:id="@+id/fancy_accordion_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:descendantFocusability="beforeDescendants"
        android:fadingEdgeLength="0dp"
        android:scrollbarStyle="outsideOverlay"
        android:scrollbars="vertical"
        android:splitMotionEvents="false"
        tools:listitem="@layout/sample_layout_collapsed"/>

3.3 Create your custom layout for collapsed and expanded item

Create your custom layout for collapsed and expanded item.

Example for collapsed item sample_layout_collapsed:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/selectableItemBackground"
    android:paddingEnd="16dp"
    android:paddingStart="16dp">
    
    <TextView
        android:id="@+id/sample_layout_collapsed_title"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentStart="true"
        android:gravity="center_vertical"
        android:textColor="@android:color/black"
        tools:text="Collapsed View"/>
        
    <com.sysdata.widget.accordion.ArrowImageView
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:layout_alignParentRight="true"
        android:tint="@android:color/black"
        app:expanded="false"/>
        
</RelativeLayout>

Example for expanded item sample_layout_expanded:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/selectableItemBackground"
    android:paddingEnd="16dp"
    android:paddingStart="16dp">

    <TextView
        android:id="@+id/sample_layout_expanded_title"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentStart="true"
        android:gravity="center_vertical"
        android:textColor="@android:color/black"
        tools:text="Expanded View"/>

    <TextView
        android:id="@+id/sample_layout_expanded_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/sample_layout_expanded_title"
        android:gravity="top"
        android:minHeight="48dp"
        android:paddingBottom="8dp"
        tools:text="I'm an Expanded View"/>

    <com.sysdata.widget.accordion.ArrowImageView
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:layout_alignParentRight="true"
        android:tint="@android:color/black"
        app:expanded="true"/>

</RelativeLayout>

3.4 Create your custom listener for item click

Create your custom listener for item click, for example:

private ItemAdapter.OnItemClickedListener mListener = new ItemAdapter.OnItemClickedListener() {
    @Override
    public void onItemClicked(ItemAdapter.ItemViewHolder<?> viewHolder, int id) {
        ItemAdapter.ItemHolder itemHolder = viewHolder.getItemHolder();
        SampleItem item = ((SampleItem) itemHolder.item);

        switch (id) {
            case ItemAdapter.OnItemClickedListener.ACTION_ID_COLLAPSED_VIEW:
                showToast(String.format("Collapsed %s clicked!", item.getTitle()));
                break;
            case ItemAdapter.OnItemClickedListener.ACTION_ID_EXPANDED_VIEW:
                showToast(String.format("Expanded %s clicked!", item.getTitle()));
                break;
            default:
                // do nothing
                break;
        }
    }
};

3.5 Initialize the FancyAccordionView

Get the reference to FancyAccordionView, set the layout for collapsed/expanded item, set the listener for item click and load your data into list.

FancyAccordionView mRecyclerView = (FancyAccordionView) findViewById(R.id.alarms_recycler_view);

// bind the factory to create view holder for item collapsed
mRecyclerView.setCollapsedViewHolderFactory(SampleCollapsedViewHolder.Factory.create(R.layout.sample_layout_collapsed), mListener);

// bind the factory to create view holder for item expanded
mRecyclerView.setExpandedViewHolderFactory(SampleExpandedViewHolder.Factory.create(R.layout.sample_layout_expanded), mListener);

// restore the expanded item from state
if (savedInstanceState != null) {
    mRecyclerView.setExpandedItemId(savedInstanceState.getLong(KEY_EXPANDED_ID, Item.INVALID_ID));
}

// populate RecyclerView with mock data
loadData();

It is also possible to define different view types.

    // bind the factory to create view holder for item collapsed of type 1
    mRecyclerView.setCollapsedViewHolderFactory(
            SampleCollapsedViewHolder.Factory.create(R.layout.sample_layout_collapsed),
            mListener,
            VIEW_TYPE_1
    );
    // bind the factory to create view holder for item collapsed of type 2
    mRecyclerView.setCollapsedViewHolderFactory(
            SampleCollapsedViewHolder.Factory.create(R.layout.sample_layout_collapsed_type2),
            mListener,
            VIEW_TYPE_2
    );

    // bind the factory to create view holder for item expanded of type 1
    mRecyclerView.setExpandedViewHolderFactory(
            SampleExpandedViewHolder.Factory.create(R.layout.sample_layout_expanded),
            mListener,
            VIEW_TYPE_1
    );
    // bind the factory to create view holder for item expanded of type 2
    mRecyclerView.setExpandedViewHolderFactory(
            SampleExpandedViewHolder.Factory.create(R.layout.sample_layout_expanded_type2),
            mListener,
            VIEW_TYPE_2
    );

Licence

  Copyright (C) 2017 Sysdata S.p.A.

  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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].