百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

ExpandableSelector

> 编程语言
开源

ExpandableSelector 是一个 Android 库,用于在动画容器中显示一系列 Button/ImageButton 小组件,这些小组件可以折叠或展开。

687 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

ExpandableSelector 是一个 Android 库,用于在动画容器中显示一系列 Button/ImageButton 小组件,这些小组件可以折叠或展开。

ExpandableSelector

ExpandableSelector is an Android library created to show a list of Button/ImageButton widgets inside a animated container which can be collapsed or expanded.

Screenshots

Usage

To use ExpandableSelector in your application you have to follow this steps:

  • 1 - Add ExpandableSelector to your layout:

 
  • 2 - During your Activity/Fragment creation lifecycle create a list of ExpandableItem instances and configure them to be used inside your ExpandableSelector widget:

private void initializeSizesExpandableSelector() {
    ExpandableSelector sizesExpandableSelector = (ExpandableSelector) findViewById(R.id.es_sizes);
    List expandableItems = new ArrayList();
    expandableItems.add(new ExpandableItem("XL"));
    expandableItems.add(new ExpandableItem("L"));
    expandableItems.add(new ExpandableItem("M"));
    expandableItems.add(new ExpandableItem("S"));
    sizesExpandableSelector.showExpandableItems(expandableItems);
}
  • 3 - To be able to listen the animation events configure a ExpandableSelectorListener instance:

private void configureExpandableSelectorListener() {

    sizesExpandableSelector.setExpandableSelectorListener(new ExpandableSelectorListener() {
          @Override public void onCollapse() {
            //Do something here
          }

          @Override public void onExpand() {
            //Do something here
          }

          @Override public void onCollapsed() {
            //Do something here
          }

          @Override public void onExpanded() {
            //Do something here
          }
        });
}
  • 4 - To be able to listen the click events configure a OnExpandableItemClickListener instance:

private void configureExpandableSelectorClickListener() {

    sizesExpandableSelector.setOnExpandableItemClickListener(new OnExpandableItemClickListener() {
          @Override public void onExpandableItemClickListener(int index, View view) {
             //Do something here
          }
        });
}

Customization

You can easily customize the appearance of your ExpandableItem instances. Just asign a value to expandableItemSyle attribute in your theme and make it reference a custom style.

Remember that declaring a ExpandableItemStyle as described before with the layout height and width is mandatory to avoid inflation errors.

The resources you can show in the Button/ImageButton widgets automatically added to ExpandableSelector are:

  • Background resource identifier configured as Button/ImageButton background.
  • Resource identifier configured as ImageButton image source.
  • Title configured as Button text.

All this information will be provided to the ExpandableSelector inside a List object created by the library user.

Some extra configuration parameters can be provided from the XML like styleable attributes:


  

The attributes you can configure are:

  • expandable_selector:hide_background_if_collapsed: Changes the background associated to the ExpandableSelector widget to a transparent one while the widget is collapsed.
  • expandable_selector:hide_first_item_on_collapse: Changes the first item visibility to View.INVISIBLE when the ExpandableSelector is collapsed.
  • expandable_selector:expand_interpolator: Changes the interpolator used in the expand animation (applies to the items), you can use an interpolator available in the platform, or create your own.
  • expandable_selector:collapse_interpolator: Changes the interpolator used in the collapse animation (applies to the items).
  • expandable_selector:container_interpolator: Changes the interpolator used in the expand & collapse animation (applies to the container)
  • expandable_selector:animation_duration: Changes the animation duration in milliseconds to the one indicated.

Add it to your project

Add ExpandableSelector dependency to your build.gradle file


dependencies{
    compile 'com.karumi:expandableselector:1.0.0'
}

or to your pom.xml if you are using Maven instead of Gradle


    com.karumi
    expandableselector
    1.0.0
    aar

Do you want to contribute?

Please, do it! We'd like to improve this library with your help :)

License

Copyright 2015 Karumi

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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言