效果图展示:

使用的第三方开源项目github地址:https://github.com/umano/AndroidSlidingUpPanel

SlidingUpPanelLayout只能有2个子view,一个sliding面板,一个主面板

demo核心代码如下:

<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"android:id="@+id/sliding_layout"android:layout_width="wrap_content"android:layout_height="425dp"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:gravity="bottom"sothree:umanoDragView="@+id/dragView"sothree:umanoOverlay="false"sothree:umanoPanelHeight="120dp"sothree:umanoParallaxOffset="100dp"sothree:umanoScrollableView="@+id/list"sothree:umanoShadowHeight="0dp"><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/transparent" /><!-- SLIDING LAYOUT --><RelativeLayoutandroid:id="@+id/dragView"android:layout_width="match_parent"android:layout_height="match_parent"android:clickable="true"android:focusable="false"><!-- 底部菜单内容,根据sothree:umanoPanelHeight大小分两层显示 --><LinearLayoutandroid:id="@+id/pull_layout"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:paddingLeft="10dp"android:paddingRight="10dp"android:paddingBottom="3dp"><ImageViewandroid:id="@+id/pull_imageview"android:layout_width="20dp"android:layout_height="20dp"android:src="@drawable/pull_up" /></LinearLayout><RelativeLayoutandroid:id="@+id/bottom_layout"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/pull_layout"android:background="@color/bg_lightblue"><TextViewandroid:id="@+id/simple"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_marginBottom="10dp"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:text="蒙奇·D·路飞 日本漫画《航海王》及其衍生作品中的主角,外号“草帽”路飞,草帽一伙、草帽大船团船长,极恶的世代之一。 橡胶果实能力者的橡胶人,悬赏金15亿贝里。梦想是找到传说中的One Piece,成为海贼王" /><LinearLayoutandroid:id="@+id/list"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/simple"android:layout_centerHorizontal="true"android:orientation="vertical"><TextViewandroid:layout_margin="10dp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="路飞性格积极乐观,爱憎分明,而且十分重视伙伴,不甘屈居于他人之下,对任何危险的事物都超感兴趣。和其他传统的海贼所不同的是,他并不会为了追求财富而杀戮,而是享受着身为海贼的冒险和自由。" /><ImageViewandroid:layout_width="match_parent"android:layout_height="100dp"android:src="@drawable/luff"/><TextViewandroid:layout_margin="10dp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="路飞(Luffy)这名字源自英语“Luff”,意即“逆风航行”,这是他想过最适合船长使用的名字。此外,他也指出路飞生下来就是运势非凡的人;只有实力和运气兼备的人,才能成就伟大功业。" /></LinearLayout></RelativeLayout></RelativeLayout></com.sothree.slidinguppanel.SlidingUpPanelLayout>

xml中关键的属性配置

sothree:umanoPanelHeight : 收缩状态下的面板高度
sothree:umanoOverlay : 是否显示阴影
sothree:umanoFadeColor : 设置阴影颜色,可设置透明,同setCoveredFadeColor
sothree:umanoScrollableView : 设置可展开的是哪个view
sothree:umanoDragView : 设置外层拖拽的view(包含umanoScrollableView)

java代码设置阴影颜色和滑动监听

 mLayout.setCoveredFadeColor(Color.parseColor("#00000000"));mLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {@Overridepublic void onPanelSlide(View panel, float slideOffset) {Log.i(TAG, "onPanelSlide, offset " + slideOffset);}@Overridepublic void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {if(mLayout.getPanelState().toString().equals(SlidingUpPanelLayout.PanelState.COLLAPSED.toString())){// 箭头pullIV.setImageResource(R.drawable.pull_up);// 遮罩层hatView.setVisibility(View.GONE);}else if(mLayout.getPanelState().toString().equals(SlidingUpPanelLayout.PanelState.EXPANDED.toString())){pullIV.setImageResource(R.drawable.pull_down);hatView.setVisibility(View.VISIBLE);}}});

demo代码地址:
https://github.com/xmliu/bottom-sliding-demo

PS:
如果底部内容背景是带有透明背景的话,透明背景下的其他层的按钮的点击事件就会被覆盖,无法点击,因为这个panel本身需要滑动来控制展开和收缩

参考博文

  1. Android自底部平滑向上滑出面板的AndroidSlidingUpPanel
  2. AndroidSlidingUpPanel库使用

Android自屏幕底部滑出更多面板的实现相关推荐

  1. 高仿途牛App下拉顶部滑出更多

    现在旅游的App可谓已经很多了,携程,去哪,途牛.个人三个都用过,感觉途牛的体验还是比较不错的,个人体验,仅供参考. 好了,上面的一段扯淡衬托了我今天要和大家分享的一个功能效果,在途牛App的行程玩法 ...

  2. android 向左滑动动画,Android Activity左边滑出,右边滑入的动画切换

    Activity的切换动画实际上是Android的View Animation(视图动画)中的Tween Animation效果,Tween Animation分为4种动画效果,分别是:alpha ( ...

  3. 如何用 Swift 编写滑出式导航面板

    原文:How to Create Your Own Slide-Out Navigation Panel in Swift 作者:Nicholas Sakaimbo 译者:kmyhy 更新说明:本教程 ...

  4. android底部滑出view,Android CoordinatorLayout与NestedScrollView基于Behavior几行代码实现底部View滑入滑出...

    Android CoordinatorLayout与NestedScrollView基于Behavior几行代码实现底部View滑入滑出 在CoordinatorLayout的Behavior出现之前 ...

  5. 【Android】Activity和PopupWindow都实现从底部弹出或滑出选择菜单或窗口

    使用Activity和PopupWindow都实现从底部弹出或滑出选择菜单或窗口 [Android]测试与popwindow PopupWindow转载自:Android PopupWindow实现从 ...

  6. Android开发之高仿百度地图底部滑出菜单

    老套路上图: 底部菜单滑出效果如上图: 首先依赖三方库 implementation 'androidx.appcompat:appcompat:1.2.0'implementation 'com.g ...

  7. android防止左向右滑出程序,Android向右滑动关闭Activity(高仿知乎微信)

    先上一个效果图,不是很清晰,凑合看下. 大概效果就是,Activity向右滑动,滑动超过屏幕的一半,就关闭,否则,恢复原来的状态. 下面让我们来看下实现原理吧. 1.配置透明主题 要想Activity ...

  8. Android开发笔记(一百零一)滑出式菜单

    可移动页面MoveActivity 滑出式菜单从界面上看,像极了一个水平滚动视图HorizontalScrollView,当然也可以使用HorizontalScrollView来实现侧滑菜单.不过今天 ...

  9. android PopupWindow实现从底部弹出或滑出选择菜单或窗口

    android PopupWindow实现从底部弹出或滑出选择菜单或窗口 http://www.open-open.com/lib/view/open1379383271818.html http:/ ...

最新文章

  1. QCon上海2015精彩演讲前瞻:一线互联网公司架构实践
  2. adobe aem_AEM中的单元测试(大声思考)
  3. Android性能优化之一:ViewStub
  4. Python使用正则表达式分割字符串
  5. pep8 python 编码规范_编码规范的重要性
  6. 亿贝html5,亿贝CALL
  7. Qt5学习笔记之QString的使用
  8. ELKF(Elasticsearch+Logstash+ Kibana+ Filebeat) 部署
  9. Ubuntu 命令技巧
  10. 数字图像处理(MATLAB)(第三版) 冈萨雷斯 中的matlab附录代码工具箱
  11. 计算机课flash课件,flash动画制作获奖课件
  12. quartz定时任务cron表达式详解
  13. 对计算机科学的认识论文,关于对计算机的认识论文
  14. 矩阵分析引论: 第三章---矩阵的标准型
  15. html中选择器是什么意思,css中的选择器是什么意思?
  16. fastboot 操作
  17. 7-38 寻找大富翁 (25 分)
  18. python在图片上画矩形
  19. 河南省经济管理学校计算机系,2020年河南省经济管理学校招生简章
  20. 大话微服务:Spring Cloud gateway+OAuth2 实现单点登录和权限控制(二) OAuth2.0 四种模式的通俗理解

热门文章

  1. 机场人员车辆定位系统方案
  2. 微信PC绿色版有什么特点
  3. 如何利用互联网思维在线上进行获客?
  4. Array 和 List 对比
  5. smc数显压力表设定方法_smc真空压力表说明书ZSE30ISE30ACN.pdf
  6. __attribute__((weak))介绍以及用法
  7. 高中信息技术新教材中python版本_我省中小学信息技术课9月换新教材
  8. 魅蓝android底层是什么意思,懂的扣个11 魅族Flyme的Android11底层安排上了?
  9. XtraReport改变报表页码以及在打印时获取用户的取消操作反馈
  10. Oracle11g安装,配置监听和数据库实例