Created
September 18, 2017 10:02
-
-
Save rezaiyan/2dcb826c3619eeda027e87b3b9a6be7d to your computer and use it in GitHub Desktop.
Custom Toast
This file contains 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
public class CustomToast { | |
public static void showToast(Context context,String message) { | |
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT); | |
toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 3, toast.getYOffset() / 3); | |
TextView textView = new TextView(context); | |
textView.setBackgroundColor(Color.DKGRAY); | |
textView.setTextColor(Color.WHITE); | |
textView.setTypeface(FontManager.Iransens(context)); | |
textView.setPadding(10, 10, 10, 10); | |
textView.setText(message); | |
toast.setView(textView); | |
toast.show(); | |
} | |
} |
This file contains 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
public class FontManager { | |
public static Typeface Iransens(Context context) { | |
return Typeface.createFromAsset(context.getAssets(), "fonts/IRANSansMobile.ttf"); | |
} | |
public static Typeface Iransens_numeric(Context context) { | |
return Typeface.createFromAsset(context.getAssets(), "fonts/IRANSansMobile(FaNum)_Bold.ttf"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment