Android Custom toast width height background picture

Source: Internet
Author: User

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"   &nbsp ;         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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.