android消息提示方法自定义,Android仿QQ消息提示实现弹出式对话框

本文在《7种形式的Android Dialog使用实例》在这篇文章的基础进行学习,具体内容如下1.概述android原生控件向来以丑著称(新推出的Material Design当另说),因此几乎所有的应用都会特殊定制自己的UI样式。而其中弹出式提示框的定制尤为常见,本篇我们将从模仿QQ退出提示框来看一下常见的几种自定义提示框的实现方式。这里使用的几种弹出框实现方法概括为以下几种:自定义Dialog...
摘要由CSDN通过智能技术生成

本文在《7种形式的Android Dialog使用实例》在这篇文章的基础进行学习,具体内容如下

1.概述

android原生控件向来以丑著称(新推出的Material Design当另说),因此几乎所有的应用都会特殊定制自己的UI样式。而其中弹出式提示框的定制尤为常见,本篇我们将从模仿QQ退出提示框来看一下常见的几种自定义提示框的实现方式。

这里使用的几种弹出框实现方法概括为以下几种:

自定义Dialog

自定义PopupWindow

自定义Layout View

Activity的Dialog样式

FragmentDialog

先看下最终的效果图:

418a278ea13668c0948959443a636d03.gif

2.实践

前面提到几种实现方式均可以达到同样的演示效果,但其中又是各有不同。这里先逐一列举各种具体实现,最后加以综述总结和归纳吧。

在此之前呢,先看一下这里实现的对话框共用布局layout/confirm_dialog.xml 。

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginLeft="5dp"

android:layout_marginRight="5dp"

android:background="@drawable/confirm_dialog_bg"

android:orientation="vertical">

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="@android:color/transparent"

android:orientation="vertical" >

android:id="@+id/title_name"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:gravity="center_horizontal"

android:paddingBottom="10dp"

android:paddingTop="15dp"

android:text="Message Title"

android:textColor="@android:color/black"

android:textSize="20sp"

android:visibility="visible" />

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@android:color/transparent"

android:orientation="vertical" >

android:id="@+id/text_view"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_marginLeft="15dp"

android:layout_marginRight="15dp"

android:layout_marginTop="10dp"

android:textColor="@android:color/black"

android:text="this is message content"

android:textSize="16dip"/>

android:layout_width="match_parent"

android:layout_height="1px"

android:layout_marginTop="15dip"

android:background="#c5c5c5" />

android:layout_width="fill_parent"

android:layout_height="50dip"

android:background="@android:color/transparent"

android:gravity="center_horizontal"

android:orientation="horizontal" >

android:id="@+id/btn_cancel"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_weight="1"

android:text="Cancel"

android:textStyle="bold"

android:textColor="#0072c6"

android:background="@drawable/confirm_dialog_cancel_selector"

android:textSize="15sp" />

android:layout_width="1px"

android:layout_height="match_parent"

android:layout_gravity="center_hor

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值