ExpandableSelector 是一个 Android 库,用于在动画容器中显示一系列 Button/ImageButton 小组件,这些小组件可以折叠或展开。
ExpandableSelector 是一个 Android 库,用于在动画容器中显示一系列 Button/ImageButton 小组件,这些小组件可以折叠或展开。
ExpandableSelector is an Android library created to show a list of Button/ImageButton widgets inside a animated container which can be collapsed or expanded.
To use ExpandableSelector in your application you have to follow this steps:
ExpandableSelector to your layout:
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);
}
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
}
});
}
OnExpandableItemClickListener instance:
private void configureExpandableSelectorClickListener() {
sizesExpandableSelector.setOnExpandableItemClickListener(new OnExpandableItemClickListener() {
@Override public void onExpandableItemClickListener(int index, View view) {
//Do something here
}
});
}
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:
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:
ExpandableSelector widget to a transparent one while the widget is collapsed.ExpandableSelector is collapsed.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
Please, do it! We'd like to improve this library with your help :)
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,或尚未同步最近议题。