2017-08-07 7 views
0

私は次のコードを使用してAndroidのトーストを回転させるようにしようとしている:回しAndroidのトースト

public static void ShowToast(){ 
    Toast toast = Toast.makeText(this, "This is toast", Toast.LENGTH_LONG); 
    View toastView = toast.getView(); 
    toastView.setRotation(90); 
    toast.setView(toastView); 
    toast.show(); 
} 

しかし、トーストは回転しません。私は間違っているの?

お返事ありがとうございます。

+0

この回答に行くを与える:https://stackoverflow.com/a/6234575/469080 –

+0

@MichaelDoddありがとうございました!そして悪いグーグルのために申し訳ない:( –

答えて

0

customtoast.setGravity(Gravity.CENTER | Gravity.CENTER、0、0);

public void showCustomToast(String fname, String lastName) { 
     Context context = getApplicationContext(); 
     LayoutInflater inflater = getLayoutInflater(); 
//  View customToastroot = inflater.inflate(R.layout.mycustom_green_toast, null); 
     View customToastroot = inflater.inflate(R.layout.custom_toast_login, null); 

     GifImageView gifImageView = (GifImageView) customToastroot.findViewById(R.id.GifImageView); 
     TextView tv_title = (TextView) customToastroot.findViewById(R.id.tv_title); 
     TextView tv_message = (TextView) customToastroot.findViewById(R.id.tv_message); 

     gifImageView.setGifImageResource(R.mipmap.valid_1); 
     tv_title.setText("Success!"); 
     tv_message.setText("Welcome " + fname + " " + lastName); 

     Toast customtoast = new Toast(context); 
     customtoast.setView(customToastroot); 

//  customtoast.SetRotation(-90, 120, 90); 


     //customtoast.setText("Authentication Done"); 
//  customtoast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL,0, 0); 
     customtoast.setGravity(Gravity.CENTER | Gravity.CENTER,0, 0); 
     customtoast.setDuration(Toast.LENGTH_SHORT); 
     customtoast.show(); 
//  overridePendingTransition(R.anim.slide_in, R.anim.slide_out); 
     overridePendingTransition(R.anim.slide_out, R.anim.slide_in); 
    } 
関連する問題