android自定义的toast样式

自定义 Toast 想要什么样式就可以写什么样式


android自定义的toast样式_第1张图片

activity

View toastView = getLayoutInflater().inflate(R.layout.toast_bg, null);
        Toast toast=new Toast(getApplicationContext());
        toast.setView(toastView);
        TextView tv=(TextView)toastView.findViewById(R.id.tv_toast);
        tv.setText("您尚未登录,请先登录");
        toast.show();


toast_bg.xml


    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@drawable/toast_bg" >

            android:id="@+id/tv_toast"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:textColor="#000000" >
   


toast_bg.xml




   
  
            android:width="1dp"
        android:color="#FFFFFF" />
  
            android:bottom="6dp"
        android:left="6dp"
        android:right="6dp"
        android:top="6dp" />

   

你可能感兴趣的:(android自定义的toast样式)