Android Custom Toast Wide height size background picture
Relativelayout layout = (relativelayout) getlayoutinflater (). Inflate (r.layout.layout_custom_toast,null); ((TextView) Layout.findviewbyid (R.id.tvcheckoutway)). SetText ("11111"); ((TextView) Layout.findviewbyid (r.id.tvpercent)). SetText ("22222"); Toast toast = new Toast (Getapplicationcontext ()); Toast.setduration (toast.length_short); Toast.setgravity (gravity.center_vertical | Gravity.bottom, 0, (int) getresources (). Getdimension (R.dimen.spacing_4)); Toast.setview (layout);//setting The view of custom toast Layout toast.show ();
Layout.xml
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Wrap_content "android:layout_height=" wrap_content "> <linearlayout sty le= "@style/style_base" android:layout_width= "200DP" android:layout_height= "48DP" android:background= " @drawable/bg_toast_data "android:gravity=" center "> <textview android:id=" @+id/tvchec Koutway "android:layout_width=" wrap_content " android:layout_height=" Wra P_content "android:layout_gravity=" center "android:gravity=" center "android:text=" AAAA "/ > <textview android:id= "@+id/tvpercent" android:layout_width= "wrap_content"   ; android:layout_height= "Wrap_content"
android:gravity= "center" android:text= "{100%}" android:textcolor= "@color/green_deep" android: Textsize= "@dimen/text_size_menu"/> </LinearLayout></RelativeLayout>
need to pay attention to is the most outside of the layout do not put the background picture, otherwise how can not change the size and width, to change only in the middle of this layer and then change
Image
Android Custom toast width height background picture