80,350
社区成员
发帖
与我相关
我的任务
分享
public static void showToast(Activity act, String str, int length) {
LayoutInflater inflater = act.getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_submit, null);
TextView text = (TextView) layout.findViewById(R.id.tv_toast_txt0);
text.setText(str);
if (sToast == null) {
sToast = new Toast(act.getApplicationContext());
}
WindowManager windowManager = act.getWindowManager();
Display display = windowManager.getDefaultDisplay();
@SuppressWarnings("deprecation")
int screenWidth = display.getWidth();
@SuppressWarnings("deprecation")
int screenHeight = display.getHeight();
Log.e(TAG, "screenWidth:"+screenWidth+
" screenHeight:"+screenHeight);
FrameLayout layout2 =
(FrameLayout)layout.findViewById(R.id.fr_toast);
layout2.getLayoutParams().width = screenWidth;
layout2.getLayoutParams().height = screenHeight;
sToast.setGravity(Gravity.CENTER, 0, 0);
sToast.setDuration(length);
sToast.setView(layout);
sToast.show();
}
你为啥要用toast来全屏显示呢,为什么不用dialog或者popupwindow呢?toast的作用是在于提示用户,作为一个界面来设计不是太好吧
弱弱的问一下 你layout里面的padding属性去掉了么?