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. 题解报告:poj 2823 Sliding Window(单调队列)

    Description An array of size n ≤ 106 is given to you. There is a sliding window of size k which is m ...

  2. BufferedStream

    处理流,包在别的流上面的流,相当于包到别的管道上面的管道. 缓冲刘: 缓冲流,就是带小桶的带缓冲区的. 那两个方法知道一下就好了,不必深究…… bis.read()    read一下读一个出来 bi ...

  3. zojDakar Rally(01背包)

    01背包 加上每次更新解题数目最多 总用时最少 因为要保证用时最少,要先把时长由小到大排序. 没排序 WA了几小时..链接 #include <iostream> #include< ...

  4. 枚举Enum通过int值或文本转为对应的枚举类型

    1.数值转枚举 如果枚举类型继承了数值类型,可以直接强制转换 public enum SourceType : byte { YC = , TS = , QK = , ZQ = } //转换方式 ; ...

  5. AJPFX解析成员变量和局部变量

    成员变量和局部变量 3.1.成员变量和局部变量 A:在类中的位置不同         * 成员变量:在类中方法外         * 局部变量:在方法定义中或者方法声明上 B:在内存中的位置不同   ...

  6. css3 transform + deviceorientation实现图片旋转效果

    1. 陀螺仪deviceorientation的使用,参考<关于陀螺仪deviceorientation>https://segmentfault.com/a/11900000071838 ...

  7. BootStrap Select2组件

    想使用Select2组件必须引用:select2.min.css和select2.min.js两个文件:如下: 页面写法很简单: 在这里多选是没有搜索功能的,只有单选的时候才会有搜索功能. Selec ...

  8. iOS - 事件处理全过程(补充)

    事件处理的完整过程 1> 先将事件对象由上往下传递(由父控件传递给子控件),找到最合适的控件来处理这个事件. 2> 调用最合适控件的touches….方法 3> 如果调用了[supe ...

  9. 认识MySQL Replication

    MySQL Replication 是 MySQL 非常有特色的一个功能,他能够将一个 MySQL Server 的 Instance 中的数据完整的复制到另外一个 MySQL Server 的 In ...

  10. C# GDI+ 画坐标(x,y)

    private void button1_Click(object sender, EventArgs e) { Graphics g = this.CreateGraphics(); g.Clear ...