自定义控件-自定义吐司
来源:互联网 发布:兄弟连php教程百度云 编辑:程序博客网 时间:2024/04/27 21:07
布局文件代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/rl_back" android:layout_gravity="center" android:background="@drawable/tips_bg" > <!-- 撑开布局 --> <View android:layout_width="180dp" android:layout_height="100dp" android:layout_centerInParent="true" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:orientation="vertical" > <ImageView android:id="@+id/tips_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="10.0dip" android:gravity="center" /> <TextView android:id="@+id/tips_msg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:lineSpacingExtra="3.0dip" android:maxWidth="180dip" android:textColor="#ffffffff" android:textSize="15sp" /> </LinearLayout></RelativeLayout>
public static CustomToast makeImgAndTextToast(Context context,CharSequence text) { //通过context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 获取inflate对象. LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflate.inflate(R.layout.view_tips, null);//加载布局文件 RelativeLayout rl_back = (RelativeLayout) view .findViewById(R.id.rl_back); ImageView img = (ImageView) view.findViewById(R.id.tips_icon); TextView tv = (TextView) view.findViewById(R.id.tips_msg); rl_back.setBackgroundResource(R.drawable.tips_bg);//設置背景圖片 img.setBackgroundResource(R.drawable.tips_smile);//設置笑臉圖片 tv.setText(text); mTost.setView(view); mTost.setGravity(Gravity.CENTER_VERTICAL,0,0); mTost.setDuration(200);//显示时间 return mTost;}
第一次在CSDN上写blog
0 0
- 自定义控件-自定义吐司
- 自定义吐司
- 自定义吐司
- 自定义吐司:
- 自定义吐司
- 自定义吐司
- 自定义吐司
- 自定义吐司
- 自定义吐司
- Android自定义吐司(Toast)
- Android自定义吐司(Toast)
- 自定义吐司Toast
- 自定义好看的吐司
- Android基础控件——Toast的自定义、按两次返回键返回桌面并弹出自定义吐司、仿映客吐司
- android自定义吐司的使用
- 安卓 自定义吐司样式
- 自定义吐司Toast(二)
- 王学岗自定义吐司和SnackBar
- AppCan赵庆华: Hybrid 混合开发正当时
- Unity Json解析
- 文件比较工具整理
- Just the Facts - 1604
- IOS开发UI基础之综合应用
- 自定义控件-自定义吐司
- iOS的IAP详解
- 网络请求(GET POST同步异步)大总结
- IOS 将16进制颜色转换成RGB
- url中加号的处理方式
- 面向对象中的重载、覆盖和隐藏
- check sdk repository 卡住
- ASP.NET MVC(1)
- 个人Python学习笔录