Android ExpandableLayout:一种可伸缩扩展的Layout


Android ExpandableLayout:一种可伸缩扩展的Layout

由于手机屏幕长度和尺寸的原因,在一些Android的开发场景中,某些特定的较为次要的二级操作选项(如安妮、播放、暂停、标签、提示、删除、新建、打开等等等)诸如此类的动作,并不一定非要一打开就拥挤的呈现给用户,毕竟手机屏幕空间有限,用户的注意力和眼球焦点有限,就算全部平铺展现给用户,用户也不见得会聚焦,反而会让用户花更多时间小心谨慎的去“研究”这些按钮或者view。
像这种设计场景,可以考虑(不一定非要如此)采用Android ExpandableLayout,Android ExpandableLayout是一个第三方开源的项目,旨在完成上述的设计和编程需求,可以实现一般的布局和ListView子item一级的伸缩扩展,其在github上的项目主页是:https://github.com/traex/ExpandableLayout 。
但是原项目直接导入有一些问题,我再次整理成可以顺利运行的项目,push到git上,使用时候直接clone到本地即可运行。重新整理调整顺利后的项目链接地址:https://github.com/zhangphil/Android-ExpandableLayout
代码运行结果如图所示:

初始化静止时候的状态:


点击伸展开:



ToggleExpandLayout是一个可折叠和展开子view的开关布局控件。它可以将它的子view以阶梯式的展开。项目地址:https://github.com/fenjuly/ToggleExpandLayout 效果图:如何使用<com.fenjuly.mylibrary.ToggleExpandLayout             android:id="@ id/toogleLayout"             android:layout_width="wrap_content"             android:layout_height="80dp"             >             <TextView                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="view 1"/>             <TextView                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="view 2"/>             <TextView                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="view"/>                      </com.fenjuly.mylibrary.ToggleExpandLayout>注意,由于ToggleExpandLayout的本质是个FrameLayout,所以必须将其高度设置为大于所有子view展开状态的高度,不能设为wrap_content。为了解决这个问题,你可以将ToggleExpandLayout的外面在加个DropDownLayout:<com.fenjuly.mylibrary.DropDownLayout         android:layout_width="match_parent"         android:layout_height="match_parent"         >         <com.fenjuly.mylibrary.ToggleExpandLayout             android:id="@ id/toogleLayout"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             >             <TextView                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="view 1"/>              <TextView                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="view 2"/>               <TextView                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="view"/>                              </com.fenjuly.mylibrary.ToggleExpandLayout> </com.fenjuly.mylibrary.DropDownL
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangphil

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值