【问题标题】:react native splash image auto height反应原生启动图像自动高度
【发布时间】:2021-05-10 14:55:17
【问题描述】:

我尝试在 react-native 中制作启动画面。 我在我的项目中安装了“react-native-splash-screen”包。我创建了一个启动画面。

我想这样做。

  • 我的图片宽度填满屏幕,高度应该保护图片比例。

所以我试试这个。

布局/launch_screen.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/background_splash"
      android:orientation="vertical">
    </LinearLayout>

drawable/background_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@color/splashscreen_bg"/>

    <item
        android:layout_width="match_parent"
        android:drawable="@drawable/splashtest"
        android:adjustViewBounds="true"
        android:gravity="center" />

</layer-list>

我该怎么做?

【问题讨论】:

    标签: android react-native splash-screen


    【解决方案1】:

    我更正了这样的 .xml 文件并解决了问题。

    background_splash.xml

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item
            android:drawable="@color/splashscreen_bg"/>    
    </layer-list>
    

    launch_screen.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/background_splash"
        android:orientation="vertical">
    
            <ImageView
            android:src="@drawable/splashtest"
            android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-18
      • 2021-10-05
      • 1970-01-01
      • 2019-06-19
      • 1970-01-01
      相关资源
      最近更新 更多