gpt4 book ai didi

Android 启动画面拉伸(stretch)

转载 作者:行者123 更新时间:2023-12-04 10:42:36 27 4
gpt4 key购买 nike

我正在尝试使用 this tutorial 创建启动画面通过使用附加主题。这是我在 styles.xml 中的启动器主题:

    <style name="AppTheme.Launcher" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="android:windowBackground">@drawable/ic_launch_screen</item>
<item name="colorPrimaryDark">@color/color_white</item>
</style>

这是 ic_launch_screen.xml文件:

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

ic_splash_screen文件已经是一个 9 补丁文件,如下所示:

enter image description here

在 Android Studio 的 9 补丁预览中显示,如果拉伸(stretch), Logo 将不会调整大小并且看起来完美对齐。

然而,当我在这种组合中使用它时,启动画面在我的华为和三星上看起来被拉长了,但在 pixel 2 模拟器上却没有:华为 Mate 10 Pro 和三星 Galaxy s9+(拉伸(stretch)方式相同):

enter image description here

在模拟器上它看起来像这样完美:

enter image description here

问题不是因为系统导航。当我在模拟器中使用三键导航时,它在华为上看起来仍然很长。

我已经尝试在 ic_launch_screen.xml 中玩耍了通过使用 <nine-patch>元素或 gravity:center属性,但它看起来更加困惑。

最佳答案

我不确定为什么 9 补丁没有扩展,但我可以提出一个解决方法。您可以创建 2 个可绘制对象,第一个带有文本 pass13,另一个带有 Logo 。现在您可以创建以下图层列表:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/color_white" />
<item>
<bitmap
android:gravity="center"
android:src="@drawable/drawable1" />
</item>
<item>
<bitmap
android:gravity="center|bottom"
android:src="@drawable/drawable2" />
</item>
</layer-list>

现在它应该可以很好地扩展。

关于Android 启动画面拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59856537/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com