Android弹出框BottomSheet
来源:互联网 发布:数据库触发器工作原理 编辑:程序博客网 时间:2024/06/05 00:18
Android弹出框BottomSheet
效果图如下:
首先:
compile 'com.flipboard:bottomsheet-core:1.5.2' compile 'com.flipboard:bottomsheet-commons:1.5.2' // optional
布局如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.flipboard.bottomsheet.BottomSheetLayout android:id="@+id/bottomsheet" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="5"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="1" android:textColor="#000000" /> </LinearLayout> </com.flipboard.bottomsheet.BottomSheetLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> <Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="100dp" android:background="@color/colorPrimary" android:text="购物" android:textColor="#000000" /> </LinearLayout></LinearLayout>
<com.flipboard.bottomsheet.BottomSheetLayout</com.flipboard.bottomsheet.BottomSheetLayout>包含的布局是弹出框的弹出位置。逻辑是:
package com.example.administrator.bottomsheetdemo;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;import android.widget.Button;import android.widget.ListView;import android.widget.Toast;import com.flipboard.bottomsheet.BottomSheetLayout;public class MainActivity extends AppCompatActivity { private ListView lv; private BottomSheetLayout bottomsheet; private Button btn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.item_tan); bottomsheet = (BottomSheetLayout) findViewById(R.id.bottomsheet); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bottomsheet.showWithSheetView(LayoutInflater.from(MainActivity.this).inflate(R.layout.activity_main, bottomsheet, false)); btn = (Button) findViewById(R.id.btn); lv = (ListView) findViewById(R.id.lv); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this, "我被点击了", Toast.LENGTH_SHORT).show(); } }); bottomsheet.dismissSheet(); } }); }}
bottomsheet.dismissSheet();意思是再次点击的话关闭
0 0
- Android弹出框BottomSheet
- 【Android】底部弹出框BottomSheet…BottomSheetDialog…BottomSheetDialogFragment实验
- [Android Demo] BottomSheet 底部弹出试图
- Android BottomSheet:底部弹出Fragment面板(4)
- 使用 DialogFragment 和 BottomSheet 实现底部弹出框
- Android Support Library - BottomSheet
- BottomSheet
- BottomSheet
- Android BottomSheet 的一些坑
- Android 原生BottomSheet 介绍及坑
- android material design之BottomSheet(六)
- Android 仿高德地图可拉伸的BottomSheet
- Android BottomSheet:以选取图片为例(2)
- Android BottomSheet:List列表或Grid网格展示(3)
- Android开发-BottomSheet的使用和BottomSheetDialogFragment的封装
- Android底部对话框的实现(BottomSheet,自定义Dialog)
- Android基础之BottomSheet的介绍和使用
- android alertdialog 弹出框
- Activity启动模式与任务栈(Task)全面深入记录
- LeetCode 20:Valid Parentheses
- iOS开发中证书相关的操作
- C# 中的一些 基本语句,循环的格式.2
- 从源码分析 HashMap
- Android弹出框BottomSheet
- oracle官网下载java8文档
- Hadoop集群安装
- 当当笔试题(有n个人成一圈,顺序排号(编号为1到n),从第一个人开始报数1到3报数),凡报到3的人出圈子,从下个人开始继续报数,直到最后一个人,问最后留下在是第几号?)
- 单例设计模式
- 如何让UDP实现可靠传输
- scipy.interpolate.lagrange
- 进程的5种终止方式
- 拓扑排序(给任务排序,UVA 10305)