Android列表背景图如何滑动,GitHub - kingideayou/SlideBottomPanel: 底部划动菜单,滑动时背景图透明度渐变,支持嵌套 ListView 或 ScrollVie...

SlideBottomPanel 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6b696e6769646561796f752d536c696465426f74746f6d50616e656c2d627269676874677265656e2e7376673f7374796c653d666c6174

底部划出视图,轻松实现「知乎日报β版」效果(效果见底部效果图)

可以划出的视图可以包裹 ListView 及 ScrollView。并且 ListView 及 ScrollView 可以在第二级或第三级视图中。

Demo apk 下载地址:SlideBottomPanelDemo 下载

推荐使用 Android Support Library 23.2 提供的 BottomSheet

更新日志

1.0.6 版本:添加了 displayPanel() 方法,直接控制视图显示

1.0.3 版本修复了多重嵌套时,隐藏 PanelTitle 时 Panel 出现跳动的 Bug

How to use 如何使用

###导入项目

Gradle

compile 'com.github.kingideayou:SlideBottomPanel:1.0.6'

Import

首先下载 SlideBottomPanel,将 SlideBottomPanel 文件夹拷贝到项目的目录下面,然后在setting.gradle文件中增加文件夹名称

include ":SlideBottomPanel"

然后在我们需要依赖这个模块的module中的build.gradle文件中加入如下代码:

compile project(':SlideBottomPanel')

布局文件

导入成功后,只需要在 XML 文件中添加如下视图(层级比较简单 FrameLayout 的子视图直接包含 ListView 或者 ScrollView)

下面布局只作简单演示,复杂效果请看 Demo.

android:id="@+id/sbv"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:sbp_title_height_no_display="55dp"

app:sbp_panel_height="380dp"

app:sbp_hide_panel_title="true"

app:sbp_background_layout="@layout/background_layout">

android:layout_width="match_parent"

android:layout_height="380dp"

android:background="#ffffff"

android:orientation="vertical">

android:id="@+id/list_view"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

android:layout_width="match_parent"

android:layout_height="55dp"

text="我是标题"

android:orientation="horizontal"

android:gravity="center_vertical"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:background="#ffffff"/>

同时也支持复杂一点的效果(知乎日报β版),子视图 FrameLayout 中包含 ViewGroup,ViewGroup 包含 ListView 或 ScrollView

android:id="@+id/sbv"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:sbp_hide_panel_title="true"

app:sbp_title_height_no_display="55dp"

app:sbp_panel_height="380dp"

app:sbp_background_layout="@layout/background_layout">

android:layout_width="match_parent"

android:layout_height="380dp"

android:background="#ffffff"

android:orientation="vertical">

android:weightSum="9"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:id="@+id/list_view"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="8"/>

android:id="@+id/tv_edit"

android:layout_weight="1"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_gravity="center_vertical"

android:gravity="center_vertical"

android:layout_marginLeft="@dimen/activity_horizontal_margin"

android:text="写点评..."/>

android:layout_width="match_parent"

android:layout_height="55dp"

text="我是标题"

android:orientation="horizontal"

android:gravity="center_vertical"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:background="#ffffff"/>

代码控制

完成布局文件后,在 Activity 中将对应的视图填充即可。

//隐藏 SlideBottomPanel

if (sbv.isPanelShowing()) {

sbv.hide();

}

//显示 SlideBottomPanel

sbv.displayPanel()

效果图

9cc2621f6a3d413028cba2e897ac4809.png

405ca75117e07876140eb37fbb3740d6.png

动图展示:

a0def1f66c9a8c3aca70fb583e0aeccc.png

ce6b0f51307081a79c1119f3910eecfa.png

鸣谢

License

Copyright 2015 NeXT

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值