Android custom toast width height background image
Android custom toast wide and high size background image
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
< pre>
android:gravity="center" android:text="{100%}" android:textColor="@color/green_deep" android:textSize="@dimen/text_size_menu" />
Note that do not place background images on the outermost layout layer. Otherwise, the size and width and height cannot be changed. You can only change the layout layer in the middle.
Image