Created
January 29, 2018 14:48
-
-
Save blazvantur/2a4918e429ec5adeaa3c531c056ba406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Toast makeText(Context context, String message, int duration, String color) { | |
LayoutCustomToastBinding binding = | |
DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.layout_custom_toast, | |
null, false); | |
binding.tvMessage.setText(message); | |
int roundRadius = (int) convertDpToPixel(context, 35); | |
GradientDrawable gradientDrawable = new GradientDrawable(); | |
gradientDrawable.setColor(Color.parseColor(color)); | |
gradientDrawable.setCornerRadius(roundRadius); | |
binding.content.setBackground(gradientDrawable); | |
Toast toast = new Toast(context); | |
toast.setDuration(duration); | |
toast.setView(binding.getRoot()); | |
return toast; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment