Toast用于向用户显示一些帮助/提示。下面我做了5中效果,来说明Toast的强大,定义一个属于你自己的Toast。
1.默认效果

\" src=http://schemas.android.com/apk/res/android "
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:padding="5dip" android:gravity="center">
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/btnSimpleToast"
android:text="默认"></Button>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:text="自定义显示位置"
android:id="@+id/btnSimpleToastWithCustomPosition"></Button>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/btnSimpleToastWithImage"
android:text="带图片"></Button>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:text="完全自定义"
android:id="@+id/btnCustomToast"></Button>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent" android:text="其他线程"
android:id="@+id/btnRunToastFromOtherThread"></Button>
</LinearLayout>

3.custom.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android "
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:background="#ffffffff" android:orientation="vertical"
android:id="@+id/llToast" >
<TextView
android:layout_height="wrap_content"
android:layout_margin="1dip"
android:textColor="#ffffffff"
android:layout_width="fill_parent"
android:gravity="center"
android:background="#bb000000"
android:id="@+id/tvTitleToast" />
<LinearLayout
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/llToastContent"
android:layout_marginLeft="1dip"
android:layout_marginRight="1dip"
android:layout_marginBottom="1dip"
android:layout_width="wrap_content"
android:padding="15dip"
android:background="#44000000" >
<ImageView
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:id="@+id/tvImageToast" />
<TextView
android:layout_height="wrap_content"
android:paddingRight="10dip"
android:paddingLeft="10dip"
android:layout_width="wrap_content"
android:gravity="center"
android:textColor="#ff000000"
android:id="@+id/tvTextToast" />
</LinearLayout>
</LinearLayout>


更多相关文章

  1. 【Android 界面效果39】android:inputType问题
  2. Android利用TextView制作跑马灯该效果
  3. 安卓开发小效果--走马灯
  4. Android 使用shape来优化界面效果
  5. android切换效果、Flutter信息类App、仿饿了么点餐、仿爱壁纸应
  6. Android设置android:clipChildren达到的特殊UI设计效果
  7. AndroidUI线程机制
  8. [置顶] Android 各类功能效果源代码集合
  9. android 设置透明效果

随机推荐

  1. Android WheelView(滑轮组件)使用
  2. android解析xml文件的方式(其三)
  3. Android面试题整理(一)
  4. cocos2d-x 2.X for Android中需要使用Ope
  5. Android——编译odex保护
  6. Andorid UI设计技巧
  7. 安卓常用属性
  8. 一键切换Android应用环境(Environment Swi
  9. Android(安卓)UI 限定字数 单独一行
  10. Android静态注册广播receiver检测WIFI连