Hus*_*y 2 react-native react-native-android react-native-ios
我创建了新的 React Native 移动应用程序,我需要将 gif 图像设置为初始屏幕。任何示例或源代码都可以帮助我做到这一点。
render() {
return (
<View style={styles.container}>
{/*<BackgroundImage source={Images.splashScreen}*/}
{/* style = {{width: 315, height: 383}} />*/}
<Image
style={{width: 300, height: 200}}
source={{uri: 'http://gifsstore.com/public/upload/gifs/15609427721560942769.gif'}} />
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
这里的这些答案似乎有点误导。问题询问如何使用 react native 将其添加到启动画面。解决方案说明了如何将 gif 添加到项目中,但没有说明如何将它们添加到启动画面。
启动画面意味着在 JS 包加载 IE 之前加载,在 JS 包加载之前render无法访问来自 react native的方法。
实际上可以直接在启动画面中有一个 gif
将此 repo 视为将 gif 集成到启动画面的示例。 https://github.com/koral--/android-gif-drawable
我实际上在今晚(2020 年 4 月 12 日)使用react native 0.62让它工作了
/layout/launch_screen/xmllayout/launch_screen.xml这@drawable/tutorial是我的 gif 标题为tutorial.gif
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:background="@color/splashscreen_bg"
android:layout_height="match_parent">
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/tutorial"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我能够通过使用来提高白屏闪光灯 <item name="android:windowDisablePreview">true</item>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
<!-- Add the following line to set the default status bar color for all the app. -->
<item name="android:statusBarColor">@color/app_bg</item>
<!-- Add the following line to set the default status bar text color for all the app
to be a light color (false) or a dark color (true) -->
<item name="android:windowLightStatusBar">false</item>
<!-- Add the following line to set the default background color for all the app. -->
<item name="android:windowBackground">@color/app_bg</item>
<!-- Prevents white screen from appearing when opening the app -->
<item name="android:windowDisablePreview">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
希望这对大家有帮助!
| 归档时间: |
|
| 查看次数: |
6108 次 |
| 最近记录: |