15

我一直在尝试为 Android 应用程序创建启动屏幕,如 正确的启动屏幕 |中所述。有风格的大书呆子牧场

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/background_splash</item>
</style>

background_splash 看起来像

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

sparrow.xml 看起来像

<vector android:height="240dp"
    android:width="240dp"
    android:viewportHeight="512.0"
    android:viewportWidth="512.0"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#e000"
        android:pathData="M407.2,55.2c-20.8,2.4 -42.9,16.8 -65.6,42.7 -4.5,5.1, lot of data here ,-8.2z" android:strokeColor="#00000000"/>
    <path android:fillColor="#cc0000"
        android:pathData="M474,98.9c-12.6,3.9 -17.8,15.3 -12.4,26.8 1.4,2.8 3.1,5.4 3.9,5.7 1.3,0.5 11.4,-0.5 20.5,-1.9 1.4,-0.2 5,-0.6 8,-1 8,-0.8 11.1,-1.6 10.8,-2.5 -0.3,-0.7 -5.1,-6.4 -21.4,-25.3 -2.4,-2.7 -4.7,-3.2 -9.4,-1.8z" android:strokeColor="#00000000"/>
</vector>

但是,我看到的问题是,由宽度和高度属性定义的 1:1 纵横比vector在设备屏幕上显示时不会保持不变。比如在android studio中显示一个圆圈如下

在安卓工作室

但是,上面的图像在设备上显示如下,因为它占据了所有可用的高度。

在设备上

4

0 回答 0