当我为启动画面创建9补丁图像时,它对于较大的设备来说太小了

时间:2015-11-24 16:19:43

标签: android splash-screen nine-patch

我决定在启动画面中使用9补丁图像 问题是,在较大的设备上,Splash Image太小了,我希望我的飞溅占据屏幕的大部分。

在较小的设备上,它很好 我不认为我正在以正确的方式创建这9个补丁图像。

有人可以指向某个网站或使用9补丁启动画面图像的GitHub存储库,它占用了所有设备上的大部分屏幕尺寸吗?

我想把它放在我的应用程序中,看看我做错了什么。

SplashTheme.xml

<resources>
  <style name="SplashTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:windowBackground">@drawable/splashscreen</item>
    <item name="android:windowNoTitle">true</item>
 </style>
</resources>

splashscreen.xml

<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <shape android:shape="rectangle" > //This is so I can have a white background
        <solid android:color="#FFFFFF" />
    </shape>
</item>
<item>
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
      android:src="@drawable/splash" 
      android:tileMode="disabled"
      android:gravity="center"
    />
</item>
</layer-list>

1 个答案:

答案 0 :(得分:5)

这个

<item>
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
      android:src="@drawable/splash" 
      android:tileMode="disabled"
      android:gravity="center"
    />
</item>

必须更改为

<item>
    <nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
      android:src="@drawable/splash" 
      android:tileMode="disabled"
      android:gravity="center"
    />
</item>

参考:http://developer.android.com/guide/topics/resources/drawable-resource.html#NinePatch