首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

施用系统样式的自定义图片加文字的Toast

2012-08-25 
使用系统样式的自定义图片加文字的Toast使用系统样式的自定义图片加文字的Toast。废话不多说,直接上代码:To

使用系统样式的自定义图片加文字的Toast

使用系统样式的自定义图片加文字的Toast。废话不多说,直接上代码:

Toast toast = Toast.makeText(this, null, Toast.LENGTH_LONG);LinearLayout layout = (LinearLayout)toast.getView();layout.setOrientation(LinearLayout.HORIZONTAL);ImageView imgView = new ImageView(this);imgView.setImageResource(R.drawable.succ);layout.addView(imgView);TextView tv = new TextView(this);tv.setLayoutParams(new  LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));tv.setGravity(Gravity.CENTER_VERTICAL);tv.setPadding(10, 0, 0, 0);tv.setText(R.string.mood_fine);layout.addView(tv);toast.show();

?附件是效果图


施用系统样式的自定义图片加文字的Toast

热点排行