大家都知道IOS的很多菜单都是从底部弹出的,这种展示方式还是很好看的,而丑爆的Android默认弹框一直都是大家一定要摒弃的,那么我们Android如何做出相应效果的弹框。下面我们就介绍这种做法。

  • 底部弹出框布局 dialog_goods_sku_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="wrap_content"><RelativeLayoutandroid:id="@+id/top_layout"android:layout_width="match_parent"android:layout_height="90dp"android:elevation="1dp"tools:ignore="UnusedAttribute"><FrameLayoutandroid:layout_width="match_parent"android:layout_height="75dp"android:background="@android:color/white"android:layout_alignParentBottom="true"android:paddingStart="120dp"><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="bottom"android:paddingBottom="5dp"android:orientation="vertical"><TextViewandroid:id="@+id/tv_total_price"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="¥88.88"android:textColor="@color/colorPrimary"android:textSize="16sp"android:textStyle="bold"tools:ignore="HardcodedText,TextViewEdits" /><TextViewandroid:id="@+id/tv_goods_no"android:layout_width="wrap_content"android:layout_height="wrap_content"android:visibility="visible"android:text="商品编码:888888"tools:ignore="HardcodedText" /></LinearLayout></FrameLayout><android.support.v7.widget.CardViewandroid:id="@+id/cardView"android:layout_width="90dp"android:layout_height="90dp"android:layout_marginEnd="14dp"android:layout_marginStart="20dp"android:layout_marginBottom="5dp"app:cardBackgroundColor="@android:color/white"app:cardCornerRadius="6dp"app:cardElevation="2dp"><ImageViewandroid:id="@+id/iv_goods"android:layout_width="match_parent"android:layout_height="match_parent"android:scaleType="centerCrop"android:src="@mipmap/aaa"tools:ignore="ContentDescription" /></android.support.v7.widget.CardView></RelativeLayout><android.support.v4.widget.NestedScrollViewandroid:id="@+id/scrollView"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/top_layout"android:background="@android:color/white"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginEnd="14dp"android:layout_marginStart="14dp"android:layout_marginTop="100dp"android:orientation="vertical"></LinearLayout></android.support.v4.widget.NestedScrollView><LinearLayoutandroid:id="@+id/bottom_layout"android:layout_width="match_parent"android:layout_height="50dp"android:layout_below="@+id/scrollView"android:orientation="horizontal"><TextViewandroid:id="@+id/tv_add_shopping_sku"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:alpha="0.8"android:background="@color/colorAccent"android:gravity="center"android:text="加入购物车"android:textColor="@android:color/white"tools:ignore="HardcodedText" /><TextViewandroid:id="@+id/tv_orders_sku"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:background="@color/colorPrimary"android:gravity="center"android:text="立即购买"android:textColor="@android:color/white"tools:ignore="HardcodedText" /></LinearLayout>
</RelativeLayout>
  • java中弹出BottomSheetDialog
private void initDialog() {BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);bottomSheetDialog.setContentView(R.layout.dialog_goods_sku_layout);//给布局设置透明背景色,让图片突出来bottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet).setBackgroundColor(getResources().getColor(android.R.color.transparent));bottomSheetDialog.show();
}

其实就是简单的两步,上面是布局,下面是把布局加载到BottomSheetDialog中就好。这个需要我们引入design包即可。

Android中BottomSheetDialog使用方法(底部弹出的Dialog)相关推荐

  1. Android自定义底部弹出窗-dialog(2种实现分析+源码)

    Android自定义底部弹出窗-dialog(2种实现分析+源码) 上线项目功能抽取,在项目开发中,我们会在许多地方会用到底部自定义弹窗,比如设置:个人账户退出,切换,照片的拍照或者相册的调出,或者一 ...

  2. 安卓开发弹窗activity风格_安卓两种底部弹出窗dialog实现方式

    [实例简介]安卓两种底部弹出窗dialog实现方式,一种是列表弹窗实现,2是灵活底部弹窗,传入布局以及控件id [实例截图] [核心代码] package com.kx.kxbottomdialog; ...

  3. android中底部弹窗,Android实现从底部弹出的Dialog示例(一)

    一.概述 先给大家看一下效果图: 点击中间的显示弹框按钮,从底部弹出来一个对话框,用户可以点击拍照或者从相册选择进行相应的操作,下面看看怎么实现. 二.代码实现 主页面布局文件,很简单,一个按钮,响应 ...

  4. Android仿IOS封装通用的弹出框Dialog和底部弹出列表选择框 仿美团顶部条件筛选框 附自定义ViewGroup

    弹出框 背景 提示与询问弹出框 实现 使用 列表选择框 实现 使用 顶部条件筛选框 实现 自定义ViewGroup 使用 总结 背景 鉴于Android提供的默认弹出框很一般,IOS的弹出框样式还不错 ...

  5. android inputmethodmanager 不自动弹出,Android中软键盘InputMethodManager的弹出和隐藏,以及显示和隐藏的监听...

    1.首先设置软键盘的弹出模式,设置在初始化View的前面 @Override protected void onCreate(Bundle savedInstanceState) { this.req ...

  6. android中使用百度地图绘制弹出框的覆盖物

    这几天在项目中引入了百度地图,实现的功能就是类似美团的地图查看周边团购那样的功能,实现的弹出框布局要比美团复杂一些. 下面直接上代码: 通过这个方法在指定的坐标创建一个覆盖物 mBaiduMap.se ...

  7. Android中实现长按照片弹出右键菜单

    场景 效果 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 获取编程相关电子书.教程推送与免费下载. 实现 将布局改为Lin ...

  8. android实现qq修改密码底部弹出框_易查分强大的“可修改列”功能:轻松实现填表、留言和信息核对...

    考试成绩公布了,想征求家长和学生的意见吗?给查询加个留言吧:需要家长填写一些表格,还在用QQ和微信群一个人一个人的留言粘贴吗?公布一些资料,想让家长自己核对一下有没有错误,家长还要告诉老师修改?用易查 ...

  9. Android Jni反射Java方法,弹出对话框

    1.创建页面 /*** @描述 C语言调用java反射方法* @项目名称 App_imooc* @包名 com.android.imooc.jni* @类名 ReflectActivity* @aut ...

最新文章

  1. 初学者的机器学习入门实战教程!
  2. RHEL6基础四十九之RHEL文件(夹)权限进阶篇
  3. MFC中获取任务栏大小
  4. 数据结构:二叉查找树(C语言实现)
  5. 【HRBUST - 1996】数学等式 (HASH 或 二分)
  6. linux syslog 删除文件_Linux没有当心删除日记文件syslog怎样办
  7. Nginx Parsing HTTP Package、header/post/files/args Sourcecode Analysis
  8. 商标申请的企业法律服务可避免法律风险
  9. 手把手教你学dsp_新课免费看| 手把手教你学DSP,C2000从入门到精通
  10. 一图读懂开源协议_一张经典图,开源协议比较
  11. 配置spring boot 内置tomcat的accessLog日志
  12. Git版本控制:Git高级教程
  13. 【图像检测】基于matlab GUI比值+归一化+相关系数遥感图像【含Matlab源码 737期】
  14. NotePad++ 正则表达式
  15. 图片转成文字:方便准确的OCR识图软件
  16. 金融学习之八——ARCH和GARCH模型应用
  17. 猎头是怎么找到合适候选人的?
  18. MyIM服务端聊天记录(网络编程作业)
  19. github followers-following相互比较
  20. 暴风魔镜S1拆解和低成本DIY适应大手机

热门文章

  1. Linux自定义日志文件设置回滚(避免信息溢出)
  2. 天下无贼是假的,天下无票倒是真的;如来神掌是假功夫,能买到车票才是真功夫。
  3. Android 画闹钟
  4. DS线性表—多项式相加
  5. 【智能制造】38页超赞PPT解读智能制造核心要素及其标准化!
  6. python网络编程好学吗_年薪30万+的python编程难不难?好学吗?
  7. el-cascader级联选择器,解决最后一级空白过滤掉空的children,并且使用props设置children等参数
  8. oracle系统监控工具oswatch简介!
  9. 蓝牙耳机哪个品牌性价比高?高性价比真无线蓝牙耳机
  10. 一款性能足够的4.5寸以下的手机