Toast in Android.
Toast in Android. / SNACKBAR/(for permanent display notification can be used)sdfsdf/
Toast.makeText(MainActivity.this, "login Successfully", Toast.LENGTH_SHORT).show();
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
FOR STYLEABLE TOAST
- First implement latest dependency.
- dependencies { implementation 'io.github.muddz:styleabletoast:2.4.0' }
- Next, go to values -> style -> create new <style name = "signuptoast"> layout
<style name="signupToast">
<item name="stColorBackground">#228B22</item>
<item name="stTextBold">true</item>
<item name="stTextColor">#fff</item>
<item name="stFont">@font/retrofont</item>
<item name="stTextSize">14sp</item>
<item name="stColorBackground">#fff</item>
<item name="stSolidBackground">true</item>
<item name="stStrokeWidth">3dp</item>
<item name="stStrokeColor">#fff</item>
<item name="stIconStart">@drawable/ic</item>
<item name="stIconEnd">@drawable/ic</item>
<item name="stLength">LONG</item> LONG or SHORT
<item name="stGravity">top</item> top or center
<item name="stRadius">5dp</item>
</style>- in Java
StyleableToast.makeText(MainActivity2.this, "Hello World!", Toast.LENGTH_LONG, R.style.signupToast).show();
new StyleableToast
.Builder(context)
.text("Hello world!")
.textColor(Color.WHITE)
.backgroundColor(Color.BLUE)
.show();
Comments
Post a Comment