Search code examples
androidtoastandroid-toast

Issue with custom Toast with color


I trying to make a custom toast with the background "Orange color", however, in the attempt I am able to get it but the field also becomes white and the text is not visible, I have attached the image

enter image description here

You can see that the text is not visible.

here is my code:

            String g= "+";
            Toast toast = Toast.makeText(getActivity(), "Click and hold on '"+g+"' icon", 
             Toast.LENGTH_SHORT);

            View view= toast.getView();
            view.setBackgroundColor(Color.parseColor("#FF791B"));

            View t = toast.getView().findViewById(android.R.id.message);
            t.setBackgroundColor(Color.parseColor("#FFFFFF"));
            toast.show();

I just want the text to be in white. Is something I am missing in the code, I am not able to get it right. Also, is there a way to make the "+" sign bold g


Solution

  • I have mode some changes here:

    TextView t = toast.getView().findViewById(android.R.id.message);
                t.setTextColor(Color.WHITE);
    

    I have saved it as textView and I was able to get the setTextColor method and I was able to change the color