android 自定义toast width height 背景图片

Android 自定义toast 宽高大小 背景图片

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 layouttoast.show();layout.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=""android:layout_width="wrap_content"android:layout_height="wrap_content"><LinearLayoutstyle="@style/style_base"android:layout_width="200dp"android:layout_height="48dp"android:background="@drawable/bg_toast_data"android:gravity="center"><TextViewandroid:id="@+id/tvCheckoutWay"android:layout_width="wrap_content"            android:layout_height="wrap_content"android:layout_gravity="center"android:gravity="center"android:text="AAAA" /><TextViewandroid: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>需要注意的是最外一层layout不要放背景图片,不然怎么都改变不了大小和宽高,要改只能在中间这层再改

图片

,并且为之实践了关怀和付出的善举。对于我性情中的易感和怨薄,

android 自定义toast width height 背景图片

相关文章:

你感兴趣的文章:

标签云: