How can I change default toast message color and background color in android?

后端 未结 15 872
执念已碎
执念已碎 2020-12-23 17:12

I want to create a toast message with background color is white and message color is black. My toast message is:

Toast.makeText(Logpage.this, \"Please Give          


        
15条回答
  •  不知归路
    2020-12-23 17:48

    Change default toast message color and background color in JAVA. You can change toast message color and background color this way..

            Toast toast=Toast.makeText(MainActivity.this,"Signin button is clicked.",Toast.LENGTH_SHORT);
            View view =toast.getView();
            view.setBackgroundColor(Color.GREEN);
            TextView toastMessage = (TextView) toast.getView().findViewById(android.R.id.message);
            toastMessage.setTextColor(Color.RED);
            toast.show();
    

    Just change toast text color this way..

            Toast toast = Toast.makeText(getApplicationContext(), "Signup button is clicked.",Toast.LENGTH_SHORT);
    
            TextView toastMessage=(TextView) toast.getView().findViewById(android.R.id.message);
            toastMessage.setTextColor(Color.BLUE);
            toast.show();
    

提交回复
热议问题