Skip to content

Instantly share code, notes, and snippets.

@brucetoo
Created August 30, 2017 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brucetoo/573a5f5b92d6b98dde9805ec4576ef6e to your computer and use it in GitHub Desktop.
Save brucetoo/573a5f5b92d6b98dde9805ec4576ef6e to your computer and use it in GitHub Desktop.
custom toast show time(not really precise)
final Toast toast = new Toast(getContext());
toast.setDuration(Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_game_guide_25, null);
((TextView) view.findViewById(R.id.txt_hint)).setText(getResources().getText(R.string.game_tool_n_phone_permission_hint));
toast.setView(view);
CountDownTimer toastCountDown = new CountDownTimer(5000, 1000 ) {
public void onTick(long millisUntilFinished) {
toast.show();
}
public void onFinish() {
toast.cancel();
}
};
toast.show();
toastCountDown.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment