android:layout_marginBottom=“34dp”
android:layout_marginTop=“20dp”
android:gravity=“center”
android:textColor=“@color/white”
android:textSize=“30sp” />
工具类
/**
- Created by meixi on 2020/11/12.
*/
public class ToastUtil {
private static Toast toast;
public static void showToastCenter(Context ctx, String str) {
Toast toast = Toast.makeText(ctx, str, Toast.LENGTH_SHORT);
toast.setGravity(0, Gravity.CENTER, Gravity.CENTER);
toast.show();
}
public static void showToastLong(Context ctx, String str) {
Toast.makeText(ctx, str, Toast.LENGTH_LONG).show();
}
public static void showToastShort(Context ctx, String str) {
Toast.makeText(ctx, str, Toast.LENGTH_SHORT).show();
}
public static void showToast(Activity activity, String toastContent, int image,int time) {
LayoutInflater inflater = activity.getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_stat_layout, null);
TextView content = layout.findViewById(R.id.tv_content);
content.setText(toastContent);
ImageView imageView = layout.findViewById(R.id.iamge);
imageVie