- Toast吐司:
Toast内容简单,不做过多介绍,Toast支持自带简单吐司,自定义吐司。内容简单可见代码,详见API。A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. For example, navigating away from an email before you send it triggers a "Draft saved" toast to let you know that you can continue editing later. Toasts automatically disappear after a timeout.
- 代码示例
activity_main.xml
1 <RelativeLayout xmlns:andro 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:paddingBottom="@dimen/activity_vertical_margin" 6 android:paddingLeft="@dimen/activity_horizontal_margin" 7 android:paddingRight="@dimen/activity_horizontal_margin" 8 android:paddingTop="@dimen/activity_vertical_margin" 9 tools:context=".MainActivity" > 10 11 <Button 12 android: 13 android:layout_width="wrap_content" 14 android:layout_height="wrap_content" 15 android:layout_alignParentTop="true" 16 android:layout_centerHorizontal="true" 17 android:layout_marginTop="190dp" 18 android:text="吐司按钮" /> 19 20 <Button 21 android: 22 android:layout_width="wrap_content" 23 android:layout_height="wrap_content" 24 android:layout_alignLeft="@+id/button1" 25 android:layout_below="@+id/button1" 26 android:layout_marginTop="20dp" 27 android:text="自定义吐司" /> 28 29 </RelativeLayout>