Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.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_Android Vectordrawable - Fatal编程技术网

Android 如何保持矢量绘图的纵横比?

Android 如何保持矢量绘图的纵横比?,android,android-vectordrawable,Android,Android Vectordrawable,我一直在尝试为Android应用程序创建一个启动屏幕,如中所述 有条不紊 <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"> <item name="android:windowBackground">@drawable/background_splash</item> </style> @可绘制/背景\u飞溅 背景水花看起来像 <?xml versio

我一直在尝试为Android应用程序创建一个启动屏幕,如中所述 有条不紊

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

@可绘制/背景\u飞溅
背景水花看起来像

<?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纵横比没有保持。例如,在android studio中显示一个圆圈,如下所示

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


什么是“不被维护”呢?这个问题存在于一些早期版本的Android中(在我的Sumsung Galaxy S4中,Android 5.0.1)。但在最新的模拟器映像中,它被修复了。没有在其他设备上测试。