Custom_toast

Custom_toast
//Step 0:custom toast no use users ne image btava tay che
//step 1:activity_mail xml ma ksoj change nai

// step:2 Toast.xml
<linearlayout android:id="@+id/root" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="horizontal" xmlns:android="http://schemas.android.com/apk/res/android">

    <imageview android:id="@+id/image" android:layout_height="wrap_content" android:layout_width="wrap_content">
    <textview android:id="@+id/text" android:layout_height="wrap_content" android:layout_width="wrap_content">

</textview></imageview></linearlayout>


step 3:MainActivity

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        LayoutInflater inflater=getLayoutInflater();
        View view=inflater.inflate(R.layout.toast,(ViewGroup)findViewById(R.id.root));

        ImageView  imageView=view.findViewById(R.id.image);
        imageView.setImageResource(R.mipmap.ic_launcher);

        TextView  textView=view.findViewById(R.id.text);
        textView.setText("Hello");

        Toast toast=new Toast(getApplicationContext());
        toast.setGravity(Gravity.CENTER_HORIZONTAL,0,0);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setView(view);
        toast.show();




    }
}

Comments

Popular posts from this blog

Seaborn

profile fragment firebase ie image and information vadu page update tay firebase ma

Payment ideal