提示框的优化之自定义Toast组件之(一)Toast组件的布局实现
开发步骤:
- 在res下layout下创建一个Toast的布局资源文件toast_customer.xml
- 在最外层布局组件中为该布局添加android:id属性
//toast_customer.xml <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root" //在最外层布局组件中为该布局添加android:id属性
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" <TextView
android:id="@+id/toastMessage"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center_horizontal|center_vertical"
android:textSize="13dp"
android:textColor="#000000"
/>
</LinearLayout>
- 在res下drawable下创建一个组件样式规则xml资源文件
//toast_border_bg.xml <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="8dp"/>
<solid android:color="#55FFFFFF"/>
<stroke android:width="0.5dp" android:color="#FFFFFF"/>
</shape>
- toast_customer.xml引用创建好的样式规则资源文件
//toast_customer.xml <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/toast_border_bg"> //引用创建好的样式规则资源文件toast_border_bg.xml <TextView
android:id="@+id/toastMessage"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center_horizontal|center_vertical"
android:textSize="22dp"
android:text="测试"
android:textColor="#000000"
/>
</LinearLayout>
运行:

提示框的优化之自定义Toast组件之(一)Toast组件的布局实现的更多相关文章
- 提示框的优化之自定义Toast组件之(二)Toast组件的业务逻辑实现
在java下org.socrates.mydiary.activity下LoginActivity下自定义一个方法showCustomerToast() public class LoginAct ...
- 提示框的优化之自定义Toast组件之(三)Toast组件优化
开发步骤: 在toast_customer.xml文件中添加一个图片组件对象显示提示图片 <?xml version="1.0" encoding="utf-8&q ...
- Android消息提示框Toast
Android消息提示框Toast Toast是Android中一种简易的消息提示框.和Dialog不一样的是,Toast是没有焦点的,toast提示框不能被用户点击,而且Toast显示的时间有限,t ...
- 使提示框居中显示&自定义提示框
ToastActivity.java文件: 1 public class ToastActivity extends AppCompatActivity { 2 private Button mbtn ...
- uni-app开发经验分享六:页面跳转及提示框
在我们开发的uni-app的过程中,页面跳转及提示框往往是我们做数据交互及结果反馈所要使用的功能,这里分享下我收集的一些方法及看法. 一:页面跳转 事件跳转 :指通过tap等事件来实现页面的跳转,跳转 ...
- toastr操作完成提示框
toastr.js组件 关于信息提示框,项目中使用的是toastr.js这个组件,这个组件最大的好处就是异步.无阻塞,提示后可设置消失时间,并且可以将消息提示放到界面的各个地方. 官方文档以及源码 源 ...
- vue2.0 自定义 提示框(Toast)组件
1.自定义 提示框 组件 src / components / Toast / index.js /** * 自定义 提示框( Toast )组件 */ var Toast = {}; var sho ...
- vue 自定义 提示框(Toast)组件
1.自定义 提示框 组件 src / components / Toast / index.js /** * 自定义 提示框( Toast )组件 */ var Toast = {}; var sho ...
- Android开发 ---构建对话框Builder对象,消息提示框、列表对话框、单选提示框、多选提示框、日期/时间对话框、进度条对话框、自定义对话框、投影
效果图: 1.activity_main.xml 描述: a.定义了一个消息提示框按钮 点击按钮弹出消息 b.定义了一个选择城市的输入框 点击按钮选择城市 c.定义了一个单选提示框按钮 点击按钮选择某 ...
随机推荐
- 分页搜索查询sql
select * from (select t.*,rownum no from " + table + " t where scbj=0)where (no>(" ...
- Mysql常用命令记录
-- 导出数据库: mysqldump -u user_name -p database_name > import_file.sql -- 执行脚本 source database.sql
- poj2785 简单二分
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 19243 Accep ...
- c#打开指定设备程序以及网址
//打开计算器 ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = @"C:\WINDOWS\ ...
- winPcap_1_开篇
什么是WinPcap WinPcap是一个基于Win32平台的,用于捕获网络数据包并进行分析的开源库. 因为有些应用程序需要直接访问网络中的数据包.也就是说,那些应用程序需要访问原始数据包,即没有被操 ...
- myeclipse10 如何把代码预览的窗口去掉
1,选择菜单: windows -> preferences2,在弹出窗口中选择General-> Editors -> FileAssociations3,在上方框内选择*.jsp ...
- HDU 5492(DP) Find a path
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5492 题目大意是有一个矩阵,从左上角走到右下角,每次能向右或者向下,把经过的数字记下来,找出一条路径是 ...
- 介绍一个成功的 Git 分支模型 Release 分支
英文原文: http://nvie.com/posts/a-successful-git-branching-model/ 中文版: 在这篇文章中,我提出一个开发模型.我已经将这个开发模型引入到我所有 ...
- 养成代码注释习惯,帮助你更好使用NetBeans导航器
在使用NetBeans编写php代码时,为了在一个类中,或者在方法库文件中快速找到你想要找的函数或方法,通常我们会使用NetBeans的导航器. 我们看一个导航器的事例: 大家知道,在php中代码习惯 ...
- poj2505-A multplication game
题意:两个人轮流用2~9来乘n,使n不断扩大,n开始为1.当给一个固定值k,谁先使n超过k谁赢. 分析:能到达必败态的状态为必胜态,只能到达必胜态的状态为必败态.对于给定的k,n>=k时为必败态 ...