An expandable layout container for Android
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 8 年前 | ||
| 8 年前 | ||
| 9 年前 | ||
| 8 年前 | ||
| 9 年前 | ||
| 5 年前 | ||
| 5 年前 | ||
| 8 年前 | ||
| 10 年前 | ||
| 10 年前 | ||
| 10 年前 | ||
| 9 年前 |
以下内容由 AI 翻译,如有问题请 点此提交 issue 反馈
可扩展布局
一个Android布局类,支持对其子视图的展开和折叠动画效果。
我创建这个库是因为测试过的所有可用库在某些情况下(比如处理旋转)都缺少功能或者行为不符合预期。
这个库尽可能地将工作交给父布局来完成,以确保渲染和尺寸计算按预期工作。这意味着即使是像LinearLayout的weight属性这样的复杂特性也能得到正确支持。
尝试演示
功能
可扩展布局支持对以下情况进行动画化:
- 固定高度和可变高度的视图:

- “手风琴”式扩展(使用两个可扩展布局)

- RecyclerView 项:

- 横向扩展:

使用方法
如果你还没有添加,首先在你的项目级的build.gradle中添加Jitpack Maven仓库:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
然后在模块级的build.gradle中引用该库:
dependencies {
[...]
implementation 'com.github.cachapa:ExpandableLayout:2.9.2'
}
将ExpandableLayout作为容器添加到你想要使其可扩展的布局或视图中:
<net.cachapa.expandablelayout.ExpandableLayout
android:id="@+id/expandable_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:el_duration="1000"
app:el_expanded="true"
app:el_parallax="0.5">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="Fixed height" />
</net.cachapa.expandablelayout.ExpandableLayout>
还支持el_duration和el_expanded属性,分别用于指定动画持续时间和布局是否应开始时处于展开状态。el_parallax可以设置为0到1之间的值,以控制在扩展过程中子视图的平移程度。
要触发动画,只需在Java代码中获取ExpandableLayout的引用,然后调用expand()、collapse()或toggle()方法即可。
项目中包含了一个完整的库示例。
许可证
版权所有 2016 Daniel Cachapa。
遵循Apache许可证版本2.0("许可证");
除非遵守许可证,否则您不得使用此文件。
您可以在以下位置获得许可证副本:
http://www.apache.org/licenses/LICENSE-2.0
除非根据适用法律要求或书面同意,软件
在许可下分发是基于“原样”的基础,
不提供任何明示或暗示的保修或条件。
有关权限和限制的具体规定,请参阅许可证书。
注脚
Gif动图是通过以下脚本生成的:https://gist.github.com/cachapa/aa829bfc717fc4f1d52c568d7ae8521e
