Android BottomSheet:底部弹出Fragment面板(4)
Android BottomSheet:底部弹出Fragment面板(4)
BottomSheet不仅可以弹出轻量级的定制好的面板(见附录文章5,6,7),还可以弹出“重”的fragment,但是此fragment是BottomSheetFragment。如果开发项目中需要更深度复杂的定制,则需要灵活的写一个fragment重新实现自己的代码设计要求,但是此fragment是需要继承自BottomSheetFragment。
写一个小例子。该例子意图从一个button按钮触发弹出底部的面板,此面板是一个fragment,该fragment可由开发者重写。
先写一个布局activity_bottom_sheet_fragment.xml,很简单:
<com.flipboard.bottomsheet.BottomSheetLayout
android:id="@+id/bottomsheet"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"> <Button
android:id="@+id/bottomsheet_fragment_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:layout_marginBottom="16dp"
android:text="@string/show" />
</RelativeLayout>
</com.flipboard.bottomsheet.BottomSheetLayout>
上层Java代码:
package com.flipboard.bottomsheet.sample; import com.flipboard.bottomsheet.R; import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; import com.flipboard.bottomsheet.BottomSheetLayout;
import com.flipboard.bottomsheet.commons.BottomSheetFragment; public final class BottomSheetFragmentActivity extends AppCompatActivity { protected BottomSheetLayout bottomSheetLayout; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bottom_sheet_fragment); bottomSheetLayout = (BottomSheetLayout) findViewById(R.id.bottomsheet); findViewById(R.id.bottomsheet_fragment_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new TestFragment().show(getSupportFragmentManager(), R.id.bottomsheet);
}
});
} public static class TestFragment extends BottomSheetFragment { @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(android.R.layout.simple_list_item_1, null);
v.setBackgroundColor(Color.LTGRAY);
v.setMinimumHeight(500); TextView text = (TextView) v.findViewById(android.R.id.text1);
text.setText("zhang phil @ csdn");
return v;
}
}
}
代码运行结果:
附录文章:
1,《Android自底部平滑向上滑出面板的AndroidSlidingUpPanel》链接地址:http://blog.csdn.net/zhangphil/article/details/51444509
2,《Android音乐、视频类APP常用控件:DraggablePanel(1)》链接地址:http://blog.csdn.net/zhangphil/article/details/51566860
3,《Android音乐、视频类APP常用控件:DraggablePanel(2)》链接地址:http://blog.csdn.net/zhangphil/article/details/51578665
4,《Android图片加载与缓存开源框架:Android Glide》链接地址http://blog.csdn.net/zhangphil/article/details/45535693 :
5,《Android BottomSheet:便捷易用的底部滑出面板(1)》链接地址:http://blog.csdn.net/zhangphil/article/details/51775955
6,《Android BottomSheet:以选取图片为例(2)》链接地址:http://blog.csdn.net/zhangphil/article/details/51776408
7,《Android BottomSheet:List列表或Grid网格展示(3)》链接地址:http://blog.csdn.net/zhangphil/article/details/51781698
Android BottomSheet:底部弹出Fragment面板(4)的更多相关文章
- 转 android 从底部弹出一个popuwindow,渐入渐出效果。我这里是用在购物车需要选择购买选项的操作。
最近要改客户端,需要实现一个从底部弹出的popuwindow,像我这种渣渣android技术,能整出popuwindow但是整不出动画,百度之,记录一下. 从下面这个地址转的 http://blog. ...
- android Dialog 底部弹出
. if (dialShareDialog == null) { dialShareDialog = new Dialog(context, R.style.dialog); dialShareDia ...
- AndroidSweetSheet:从底部弹出面板(1)
AndroidSweetSheet:从底部弹出面板(1) AndroidSweetSheet又是一个从底部弹出面板的开源项目.我在以前写的文章中介绍了不少这些项目,见附录文章5,6,7,8.现在 ...
- Android 底部弹出Dialog(横向满屏)
项目中经常需要底部弹出框,这里我整理一下其中我用的比较顺手的一个方式(底部弹出一个横向满屏的dialog). 效果图如下所示(只显示关键部分): 步骤如下所示: 1.定义一个dialog的布局(lay ...
- Android Demo---实现从底部弹出窗口
在前面的博文中,小编简单的介绍了如何制作圆角的按钮以及圆角的图片,伴着键盘和手指之间的舞步,迎来新的问题,不知道小伙伴有没有这样的经历,以App为例,点击头像的时候,会从底部弹出一个窗口,有从相册中选 ...
- [deviceone开发]-底部弹出选择
一.简介 个人上传的第一个示例源码,两天空闲时间写的,一点简单组件,写的挺乱还没啥注释,仅供新手学习. 底部弹出选择,可滑动选择选项,如果停留在选项中间,可自动校正位置,加了一点简单的动画效果,需要的 ...
- 仿iOS底部弹出popUpWindow
上面为弹出来的效果 popUpWindow布局: <?xml version="1.0" encoding="utf-8"?> <Linear ...
- 安卓系统浏览器中select下拉按钮无法弹出选择面板奇怪问题解决
今天遇到个让人崩溃的问题: 平台: 安卓 4.0 描述: 使用 appcan 开发 hybrid 应用,手机上点击下拉选框按钮无法弹出选择面板. 说明: 发现 webkit 内核 position:f ...
- Android软键盘弹出,覆盖h5页面输入框问题
之前我们在使用vue进行 h5 表单录入的过程中,遇到了Android软键盘弹出,覆盖 h5页面 输入框 问题,在此进行回顾并分享给大家: 系统:Android 条件:当输入框在可视区底部或者偏下的位 ...
随机推荐
- Object C学习笔记18-SEL,@ selector,Class,@class--转
一. SEL 类型 在上一篇介绍了几个方法,都只是介绍了其使用方式但是没有具体介绍参数: - (id)performSelector:(SEL)aSelector; - (id)performSele ...
- 【原】无脑操作:Eclipse + Maven + jFinal + MariaDB 环境搭建
一.开发环境 1.windows 7 企业版 2.Eclipse IDE for Enterprise Java Developers Version: 2019-03 (4.11.0) 3.JDK ...
- Android开发中使用数据库时出现java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
最近在开发一个 App 的时候用到了数据库,可是在使用数据库的时候就出现了一些问题,在我查询表中的一些信息时出现了一下问题: Caused by: java.lang.IllegalStateExce ...
- git忽略文件权限的检查
在linux上配置了一个samba服务器,方便在linux上通过ide修改代码,然后发现一个很烦人的问题,就是没有修改权限,在使用命令 chmod 777 filename后可以修改了,然而使用git ...
- Android 更新方案实现
需求说明 为了保证自己 APP 的新版本使用率,现在有很多已有的“软件更新”框架供各位使用,本文的主要内容是如何自己动手来实现软件的后台下载,更新. 下面详细说明下软件更新的逻辑,流程图如下: 每步详 ...
- 使用Jenkins进行android项目的自动构建(4)
加入单元测试 android单元测试很多都是使用Instrumentation进行的,这里讲的是试用JUnit,为什么用JUnit呢?因为使用Instrumentation需要打包apk安装,然后再进 ...
- 使用Jenkins进行android项目的自动构建(2)
Maven and POM 1. 什么是Maven? 官方的解释是: http://maven.apache.org/guides/getting-started/index.html#What_is ...
- php常用的一些代码
1.获取用户真实ip function getIP() { if (getenv("HTTP_X_FORWARDED_FOR")) { // 这个提到最前面,作为优先级,nginx ...
- python3.x 判断当前版本【简单版】
import sys,string Major_Version_Number = 0 #当前python的主版本 Minor_Version_Number = 0 #当前python的次版本 def ...
- python mail
转载一个不错python mail封装 #!/usr/bin/python from email.MIMEText import MIMEText from email.MIMEMultipart i ...