Activity:

 package com.example.editortoast;

 import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.bt).setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
toastShow();
}
});
} private void toastShow() {
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
View view = inflater.inflate(R.layout.item_toast, null);
TextView textView1 = (TextView) view.findViewById(R.id.TextView_1);
textView1.setText("Toast1"); Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(0);
toast.setView(view);
toast.show();
}
}

activity_main.xml:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.editortoast.MainActivity" > <Button
android:id="@+id/bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击" /> </RelativeLayout>

item_toast.xml:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <ImageView
android:id="@+id/image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" /> <TextView
android:id="@+id/TextView_1" android:textSize="30sp"
android:textColor="@android:color/holo_red_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/image" /> </RelativeLayout>

自定义Toast的显示效果的更多相关文章

  1. 023 Android 自定义Toast控件

    1.Toast自定义控件工具类 package com.example.administrator.test62360safeguard.Utils; import android.content.C ...

  2. Android带图片的Toast(自定义Toast)

    使用Android默认的Toast Toast简介: Toast是一个简单的消息显示框,能够短暂的出现在屏幕的某个位置,显示提示消息. 默认的位置是屏幕的下方正中,一般Toast的使用如下: Toas ...

  3. 自定义Toast和RatingBar的简单用例

    Toast是一个包含用户点击消息.Toast类会帮助你创建和显示这些.Android中的Toast是一种简易的消息提示框. 当视图显示给用户,在应用程序中显示为浮动 向右划动五角星增加 单击按钮显示自 ...

  4. 朝花夕拾-android 自定义toast

    在一个只有你而且还未知的世界中,不去探索未知,死守一处,你到底在守什么呢? 作为一个目前的android程序员,可能过去写着delphi的代码,可能未来回去搭建服务器.不管怎样,你现在是一名安卓程序员 ...

  5. Android 自定义Toast

    自定义Toast 其实就是自定义布局文件 感觉利用Dialog或者PopupWindow做也差不多 上图上代码 public class MainActivity extends Activity { ...

  6. Android Toast 设置到屏幕中间,自定义Toast的实现方法,及其说明

    http://blog.csdn.net/wangfayinn/article/details/8065763 Android Toast用于在手机屏幕上向用户显示一条信息,一段时间后信息会自动消失. ...

  7. Android开发必知--自定义Toast提示

    开发过Android的童鞋都会遇到一个问题,就是在打印Toast提示时,如果短时间内触发多个提示,就会造成Toast不停的重复出现,直到被触发的Toast全部显示完为止.这虽然不是什么大毛病,但在用户 ...

  8. android 自定义Toast显示风格

    1.创建一个自己想要显示Toast风格的XML如下代码(toast_xml.xml): <?xml version="1.0" encoding="utf-8&qu ...

  9. 自定义Toast

    简易自定义Toast public class MainActivity extends ListActivity );//边角         gradientDrawable.setGradien ...

随机推荐

  1. Oracle常用命令1

    一. 安装是用户管理: sqlplus /nolog; connect /as sysdba; alter user sys identified by change_on_install; alte ...

  2. (easy)LeetCode 219.Contains Duplicate II

    Given an array of integers and an integer k, find out whether there there are two distinct indices i ...

  3. [POJ 1155] TELE (树形dp)

    题目链接:http://poj.org/problem?id=1155 题目大意:电视台要广播电视节目,要经过中转机构,到观众.从电视台到中转商到观众是一个树形结构,经过一条边需要支付成本.现在给你每 ...

  4. Oracle Dataguard Standby Redo Log的两个实验

    在Data Guard环境中,Standby Redo Log是一个比较特殊的日志类型.从最新的DG安装指导中,都推荐在Primary和Standby端,都配置Standby Redo Log. 简单 ...

  5. ARM的QT phonon 的移植

    Phonon是QT提供的一套多媒体框架,提供多媒体播放图形界面和回放的功能,QT也是通过phonon来实现跨平台的多媒体播放.应用程序不需要关心多媒体播放到底是由什么实现的(如gstreamer.xi ...

  6. OC基础(19)

    类扩展(Class Extension) Block基本概念 typedef和Block Block注意事项 *:first-child { margin-top: 0 !important; } b ...

  7. python学习(三):matplotlib学习

    前言:matplotlib是一个python的第三方库,里面的pyplot可以用来作图.下面来学习一下如何使用它的资源. 一.使用前 首先在python中使用任何第三方库时,都必须先将其引入.即: i ...

  8. 文件的输出与载入之java操作

    一.前言 学习java没多久,关键是没怎么系统学过.都是看别人的代码来学习的.今天就把一直以来让我头痛的java  IO 的一些基本操作来记录下来,加深记忆. 二.java导入文件到内存中 首先放一个 ...

  9. SQL必知必会笔记(1)

    去SQL AXDB 中Query数据 Open the SQL > Connect > Select AXDB > new Query select REFID, ITEMID, R ...

  10. Fiddler录制jmeter脚本--V4.4..0.1版本

      圣诞节到了,圣诞老人送平安,我们送技术,我们知道以前jmeter的脚本来源有三个,手动书写.badboy录制.自带的录制功能(jmeter3.0该功能还比较好),目前我们又多了一个fiddler生 ...