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

ExpandableLayout

> 设计协作
开源

可扩展的 LinearLayout

1.2K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

可扩展的 LinearLayout

ExpandableLayout

可扩展的 LinearLayout

设置

依赖关系

gradle
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    compile 'com.github.iammert:ExpandableLayout:1.4.1'
}

布局

xml

设置渲染器

java
expandableLayout.setRenderer(new ExpandableLayout.Renderer() {
    @Override
    public void renderParent(View view, FruitCategory model, boolean isExpanded, int parentPosition) {
        ((TextView) view.findViewById(R.id.tvParent)).setText(model.name);
    }

    @Override
    public void renderChild(View view, Fruit model, int parentPosition, int childPosition) {
        ((TextView) view.findViewById(R.id.tvChild)).setText(model.name);
    }
});

设置监听器

java
expandableLayout.setExpandListener(new ExpandCollapseListener.ExpandListener() {
    @Override
    public void onExpanded(int parentIndex, FruitCategory parent, View view) {
        //Layout expanded 
    }
});

expandableLayout.setCollapseListener(new ExpandCollapseListener.CollapseListener() {
    @Override
    public void onCollapsed(int parentIndex, FruitCategory parent, View view) {
        //Layout collapsed
    }
});

添加分节或子节

java
Section section = new Section<>();

//defaut is false
section.expanded = true;

FruitCategory fruitCategory = new FruitCategory("Fruits");
Fruit fruit1 = new Fruit("Apple");
Fruit fruit2 = new Fruit("Orange");

section.parent = fruitCategory;
section.children.add(fruit1);
section.children.add(fruit2);

expandableLayout.addSection(section);
expandableLayout.addChild(fruitCategory, new Fruit("Grape"));

过滤父节点和子节点

java
//make your parent class filterable
class FruitCatefory implements Filterable{}

//make your child class filterable
class FruitCatefory implements Filterable{}

现在,您可以在父节点或子节点中搜索。布局将自动更新。

java
expendableLayout.filterParent("SEARCH PARAM")
//or
expendableLayout.filterChildren("SEARCH PARAM")

许可证

Copyright 2017 Mert Şimşek. 根据 Apache 许可证第 2.0 版 (以下简称"许可证") 许可 您不得使用此文件

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

Javaandroiddesignexpandableexpandablelayout

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

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类设计协作
定价开源

> 相关工具

F
Figma
协作式界面设计工具
S
sketch-wakatime
Sketch plugin for automatic time tracking and metrics generated from your Sketch usage.
Q
QuickColor
Quickly apply fills from the global or document color palettes to selected elements - 🎨