How to Customise Toast in Android?

前端 未结 6 491
礼貌的吻别
礼貌的吻别 2021-01-05 05:06

Is it possible to make Customize Toast in Android. like if can we place in it image icon and place button.

6条回答
  •  星月不相逢
    2021-01-05 05:34

    You can also use the regular makeText() and handle the getView() to set an image next to see the next.

    Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    TextView tv = (TextView) toast.getView().findViewById(android.R.id.message);
    if (null!=tv) {
        tv.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
        tv.setCompoundDrawablePadding(context.getResources().getDimensionPixelSize(R.dimen.padding_toast));
    

提交回复
热议问题