react-native-android - 如何在本机反应中将图像添加到吐司,有可能吗?
问题描述
从“react-native-View-Toast”导入 Toast
在这里,我正在尝试向 toast 添加图像以查看其工作原理,并且我想知道 toast 库的类型以及在 react-native 中的用途
解决方案
您可以使用 setView() 方法将 imageview 或任何视图添加到 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上查看的库
推荐阅读
- python - python openAI复古模块
- python-3.x - 从 CSV 文件中删除行
- graphql - GraphQL Yoga 提供的为 Prisma 声明字段的正确方法,但在解析器中不需要
- php - 计算特定元值上每个值的出现次数
- python - 为什么 python 列表的 x[False] 和 x[True] 有效?
- angularjs - 将 JBoss Forge AngularJs 插件更新到 Angular 6
- python - wxPython 将 wx.StaticBitmap 添加到 wx.GridBagSizer
- python - 使用 discord.py 让机器人响应图像
- javascript - Vuevalidate 插件 -$v 未在单个文件组件中定义
- typescript - 从编译中排除打字稿文件的某些部分?