如何解决如何在本地反应中添加图像到烤面包,这可能吗?
从“ react-native-View-Toast”导入吐司
在这里,我试图将图像添加到吐司,以查看其工作方式,并且我想了解吐司库的类型 并在react-native中使用
解决方法
您可以使用setView()方法将图像视图或任何视图添加到Toast通知中,并根据需要使用此方法来自定义Toast。
在这里,我创建了一个自定义布局文件,将其填充到Toast通知中,然后通过setView()方法在Toast中使用了此布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relativeLayout1"
android:background="@android:color/white">
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView1" android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="PM is here"
android:gravity="center"
android:textColor="@android:color/black">
</TextView>
<ImageView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:src="@drawable/new_logo"
android:layout_below="@+id/textView1"
android:layout_margin="5dip"
android:id="@+id/imageView1">
</ImageView>
<TextView
android:id="@+id/textView2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="This is the demo of Custom Toast Notification"
android:gravity="center"
android:layout_below="@+id/imageView1"
android:textColor="@android:color/black">
</TextView>
</RelativeLayout>
对于您可以在以下位置查看的库 openbase.io
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。