Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android “布局”和“可绘制”的居中方式不同_Android_React Native_Android Linearlayout_Splash Screen_Android Drawable - Fatal编程技术网

Android “布局”和“可绘制”的居中方式不同

Android “布局”和“可绘制”的居中方式不同,android,react-native,android-linearlayout,splash-screen,android-drawable,Android,React Native,Android Linearlayout,Splash Screen,Android Drawable,我的启动屏幕有两种布局,基本上由一个位于屏幕中心的图标组成 其中之一是drawable/launch\u screen.xml。这一个用于AppTheme <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:

我的启动屏幕有两种布局,基本上由一个位于屏幕中心的图标组成

其中之一是
drawable/launch\u screen.xml
。这一个用于
AppTheme

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

    <item>
        <bitmap
            android:gravity="center"
            android:src="@android:drawable/ic_menu_camera" />
    </item>

</layer-list>
如果您想了解详细信息,我构建了如下启动屏幕机制。当应用程序打开时,
AppTheme
显示
drawable/launch\u screen
作为背景,然后进入启动屏幕并播放
layout/launch\u screen

因此,这些文件基本上是一个以空白屏幕为中心的图标,没有任何其他样式。我希望他们都能完美地居中。然而,在现实中,它们看起来像:

第一张图片位于
可绘制
中,第二张图片位于
布局
中。如您所见,第二个是使用
LinearLayout
构建的,它的位置稍高。由于这些屏幕一个接一个地显示,因此感觉图标向上移动


我曾尝试在ImageView中添加边距或填充,但在不同的设备中呈现的效果不同。此外,我还尝试使用带有不同参数和组合的
gravity
layout\u gravity
,但它们的中心不完全相同。我想状态栏可能会导致这个问题,但状态栏总是在那里,应用程序总是全屏的。你知道为什么会出现这种定心问题吗?提前感谢。

我认为这是因为活动背景忽略了底部导航偏移。这种行为似乎没有问题

我认为这是因为活动背景忽略了底部导航偏移。这种行为似乎没有问题

你找到解决方案了吗?你找到解决方案了吗?
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/launch_screen</item>
</style>
<?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="@android:color/black"
    android:gravity="center"
    android:orientation="vertical">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_menu_camera" />
</LinearLayout>