ExpandableSelector [![Build Status](https://travis-ci.org/Karumi/ExpandableSelector.svg?branch=master)](https://travis-ci.org/Karumi/ExpandableSelector) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.karumi/expandableselector/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.karumi/expandableselector) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ExpandableSelector-green.svg?style=flat)](https://android-arsenal.com/details/1/1987)
==================
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
-----------
![Demo Screenshot][1]
Usage
-----
To use ``ExpandableSelector`` in your application you have to follow this steps:
* 1 - Add ``ExpandableSelector`` to your layout:
```xml
<com.karumi.expandableselector.ExpandableSelector
android:id="@+id/es_sizes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
```
* 2 - During your Activity/Fragment creation lifecycle create a list of ``ExpandableItem`` instances and configure them to be used inside your ``ExpandableSelector`` widget:
```java
private void initializeSizesExpandableSelector() {
ExpandableSelector sizesExpandableSelector = (ExpandableSelector) findViewById(R.id.es_sizes);
List<ExpandableItem> expandableItems = new ArrayList<ExpandableItem>();
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:
```java
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:
```java
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.
```xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="expandableItemStyle">@style/ExpandableItemStyle</item>
</style>
<style name="ExpandableItemStyle">
<item name="android:layout_height">@dimen/item_size</item>
<item name="android:layout_width">@dimen/item_size</item>
<item name="android:background">@drawable/bg_item_with_title</item>
<item name="android:layout_margin">@dimen/item_margin</item>
<item name="android:textColor">@color/gray</item>
<item name="android:textSize">@dimen/item_text_size</item>
</style>
```
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<ExpandableItem>`` object created by the library user.
Some extra configuration parameters can be provided from the XML like styleable attributes:
```xml
<com.karumi.expandableselector.ExpandableSelector
android:layout_width="wrap_content"
android:layout_height="wrap_content"
expandable_selector:hide_background_if_collapsed="true"
expandable_selector:hide_first_item_on_collapse="true"
expandable_selector:expand_interpolator="@android:anim/accelerate_interpolator"
expandable_selector:collapse_interpolator="@android:anim/decelerate_interpolator"
expandable_selector:container_interpolator="@android:anim/accelerate_decelerate_interpolator"
expandable_selector:animation_duration="100">
```
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
```groovy
dependencies{
compile 'com.karumi:expandableselector:1.0.0'
}
```
or to your ``pom.xml`` if you are using Maven instead of Gradle
```xml
<dependency>
<groupId>com.karumi</groupId>
<artifactId>expandableselector</artifactId>
<version>1.0.0</version>
<type>aar</type>
</dependency>
```
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.
[1]: ./art/screenshot_demo_1.gif
没有合适的资源?快使用搜索试试~ 我知道了~
ExpandableSelector-master.zip_android
共69个文件
xml:25个
png:20个
java:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 79 浏览量
2022-09-24
20:40:11
上传
评论
收藏 763KB ZIP 举报
温馨提示
android app on langue java
资源推荐
资源详情
资源评论
收起资源包目录
ExpandableSelector-master.zip (69个子文件)
ExpandableSelector-master
.travis.yml 214B
gradlew.bat 2KB
gradlew 5KB
config
checkstyle
checkstyle.xml 5KB
art
screenshot_demo_1.gif 764KB
gradle.properties 763B
sample
src
main
res
drawable-v21
bg_item_with_title.xml 992B
item_pink.xml 991B
item_brown.xml 992B
item_green.xml 992B
item_orange.xml 993B
drawable
bg_item_with_title.xml 889B
item_pink.xml 888B
item_brown.xml 891B
item_green.xml 889B
bg_expandable_selector.xml 854B
item_orange.xml 890B
bg_expandable_selector_dark.xml 854B
mipmap-hdpi
ic_logo_karumi.png 2KB
ic_device_hub_black.png 329B
ic_gamepad_black.png 218B
ic_keyboard_arrow_down_black.png 197B
ic_keyboard_arrow_up_black.png 180B
values
colors.xml 951B
themes.xml 825B
strings.xml 849B
styles.xml 2KB
integers.xml 793B
dimens.xml 948B
mipmap-xxhdpi
ic_logo_karumi.png 4KB
ic_device_hub_black.png 600B
ic_gamepad_black.png 315B
ic_keyboard_arrow_down_black.png 306B
ic_keyboard_arrow_up_black.png 269B
mipmap-mdpi
ic_logo_karumi.png 1KB
ic_device_hub_black.png 254B
ic_gamepad_black.png 167B
ic_keyboard_arrow_down_black.png 160B
ic_keyboard_arrow_up_black.png 149B
mipmap-xhdpi
ic_logo_karumi.png 3KB
ic_device_hub_black.png 400B
ic_gamepad_black.png 224B
ic_keyboard_arrow_down_black.png 257B
ic_keyboard_arrow_up_black.png 244B
layout
main_activity.xml 3KB
java
com
karumi
expandableselector
sample
MainActivity.java 7KB
AndroidManifest.xml 1KB
.gitignore 7B
build.gradle 334B
gradle
wrapper
gradle-wrapper.jar 49KB
gradle-wrapper.properties 232B
expandableselector
src
main
res
values
attrs.xml 1KB
layout
expandable_item_image_button.xml 778B
expandable_item_button.xml 773B
java
com
karumi
expandableselector
OnExpandableItemClickListener.java 889B
animation
AbstractAnimationListener.java 1KB
ExpandableSelectorAnimator.java 10KB
ResizeAnimation.java 2KB
ExpandableSelector.java 13KB
ExpandableSelectorListener.java 870B
ExpandableItem.java 2KB
AndroidManifest.xml 730B
.gitignore 7B
build.gradle 263B
.gitignore 370B
README.md 7KB
settings.gradle 40B
LICENSE.txt 11KB
build.gradle 416B
共 69 条
- 1
资源评论
weixin_42651887
- 粉丝: 79
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功