@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btnOKButt:
displayToast("My text");
startActivity(new Intent(Activity1.this, Activity2.class));
finish();
break;
}
}
private void displayToast(String s) {
//the default toast view group is a relativelayout
Toast toast = Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG);
LinearLayout toastLayout = (LinearLayout) toast.getView();
TextView toastTV = (TextView) toastLayout.getChildAt(0);
toast.getView().setBackgroundColor(Color.BLACK);
toast.setGravity(Gravity.FILL, 0, -250);
toastTV.setTextSize(30);
toast**strong text**.show();
}
}
I would like to have the toast to fill the whole background and still have the text in the middle. But if I use 'Gravity.FILL' I always have the text at the top. What should one do?