Created
July 17, 2019 00:53
-
-
Save EJunWhite/2f58d98c97ce97bc597513625e2fce11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Snackbar snackbar; | |
mBinding.searchEdit.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
hideSnackBar(); | |
} | |
}); | |
mBinding.searchEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() { | |
@Override | |
public void onFocusChange(View v, boolean hasFocus) { | |
hideSnackBar(); | |
} | |
}); | |
void showSnackBar(View view, String message, int duration) { | |
hideSnackBar(); | |
if (snackbar == null) { | |
snackbar = Snackbar.make(view, message, duration); | |
} | |
snackbar.setActionTextColor(getResources().getColor(android.R.color.white)); | |
View snackbarView = snackbar.getView(); | |
int snackbarTextId = android.support.design.R.id.snackbar_text; | |
TextView textView = (TextView) snackbarView.findViewById(snackbarTextId); | |
// FIXME : Fixed Font | |
Typeface custom_font = ResourcesCompat.getFont(getActivity(), com.ejun.library.R.font.noto_sans_kr_regular); | |
textView.setIncludeFontPadding(false); | |
textView.setTypeface(custom_font); | |
textView.setTextColor(getActivity().getResources().getColor(android.R.color.white)); | |
snackbarView.setBackgroundColor(Color.BLACK); | |
snackbar.getView().setVisibility(View.VISIBLE); | |
snackbar.show(); | |
} | |
void hideSnackBar() { | |
if (snackbar != null) { | |
snackbar.getView().setVisibility(View.GONE); | |
snackbar.dismiss(); | |
} | |
snackbar = null; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment