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)的更多相关文章

  1. 转 android 从底部弹出一个popuwindow,渐入渐出效果。我这里是用在购物车需要选择购买选项的操作。

    最近要改客户端,需要实现一个从底部弹出的popuwindow,像我这种渣渣android技术,能整出popuwindow但是整不出动画,百度之,记录一下. 从下面这个地址转的 http://blog. ...

  2. android Dialog 底部弹出

    . if (dialShareDialog == null) { dialShareDialog = new Dialog(context, R.style.dialog); dialShareDia ...

  3. AndroidSweetSheet:从底部弹出面板(1)

     AndroidSweetSheet:从底部弹出面板(1) AndroidSweetSheet又是一个从底部弹出面板的开源项目.我在以前写的文章中介绍了不少这些项目,见附录文章5,6,7,8.现在 ...

  4. Android 底部弹出Dialog(横向满屏)

    项目中经常需要底部弹出框,这里我整理一下其中我用的比较顺手的一个方式(底部弹出一个横向满屏的dialog). 效果图如下所示(只显示关键部分): 步骤如下所示: 1.定义一个dialog的布局(lay ...

  5. Android Demo---实现从底部弹出窗口

    在前面的博文中,小编简单的介绍了如何制作圆角的按钮以及圆角的图片,伴着键盘和手指之间的舞步,迎来新的问题,不知道小伙伴有没有这样的经历,以App为例,点击头像的时候,会从底部弹出一个窗口,有从相册中选 ...

  6. [deviceone开发]-底部弹出选择

    一.简介 个人上传的第一个示例源码,两天空闲时间写的,一点简单组件,写的挺乱还没啥注释,仅供新手学习. 底部弹出选择,可滑动选择选项,如果停留在选项中间,可自动校正位置,加了一点简单的动画效果,需要的 ...

  7. 仿iOS底部弹出popUpWindow

    上面为弹出来的效果 popUpWindow布局: <?xml version="1.0" encoding="utf-8"?> <Linear ...

  8. 安卓系统浏览器中select下拉按钮无法弹出选择面板奇怪问题解决

    今天遇到个让人崩溃的问题: 平台: 安卓 4.0 描述: 使用 appcan 开发 hybrid 应用,手机上点击下拉选框按钮无法弹出选择面板. 说明: 发现 webkit 内核 position:f ...

  9. Android软键盘弹出,覆盖h5页面输入框问题

    之前我们在使用vue进行 h5 表单录入的过程中,遇到了Android软键盘弹出,覆盖 h5页面 输入框 问题,在此进行回顾并分享给大家: 系统:Android 条件:当输入框在可视区底部或者偏下的位 ...

随机推荐

  1. E. Dasha and Puzzle 数学题

    http://codeforces.com/contest/761/problem/E 给出一颗树,要求在坐标系中用平行于坐标轴的线描绘出来. 要求边不能相交,而且点的坐标唯一. 注意到2^1 + 2 ...

  2. JSP页面自动刷新

    1.页面自动刷新:把如下代码加入<head>区域中<meta http-equiv="refresh" content="20">,其中 ...

  3. [转]Entity Framework and SQL Azure

    本文转自:https://msdn.microsoft.com/zh-cn/library/gg190738 Julie Lerman http://thedatafarm.com April 201 ...

  4. 阿里云服务器安装ss使用

    下载安装服务器版shadowsocks yum install epel-release yum update yum install python-setuptools m2crypto super ...

  5. C语言基础-运算符

    sizeof()运算符 •sizeof可以用来计算一个变量或者一个常量.一种数据类型所占的内存字节数 •sizeof一共有3种形式   1.sizeof( 变量\常量 )      sizeof(10 ...

  6. url传值的长度限制解决办法

    今天写到两个页面传值,刚开始通过url上加参数进行传值, var strLink = "my.asp?str1=" + str1List + "&str2=&qu ...

  7. 迅为IMX6UL开发板

    迅为iMX6UL开发板采用核心板加底板形式,核心板使用邮票孔方式连接,牢固耐用.处理器ARM®Cortex®-A7内核,运行速度高达528 MHz.512MDDR内存,8G EMMC存储,板截双网口, ...

  8. jquery 微信端 点击物理返回按钮,弹出提示框

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. Oracle中的执行计划

    使用autotrace sqlplus系统参数:SQL> set autotrace trace onSQL> select * from dual;DUM---XExecution Pl ...

  10. bat2exe 就是这么简单 白研究半天VC++了

    bat2exe 就是这么简单 白研究半天VC++了 结果:bat2exe编译的执行文件会被杀毒软件查杀.