Reputation: 1443
I've got a splash screen problem where I've got a simple logo I'd like to be roughly in the center of the screen. For some reason, the drawable I have is taking up the whole screen, and won't center my image neatly in the center. I've heard of 9-patch images, but I'm not sure if that's applicable to this (I think this is for icons?). Anyway, here is what I have for a drawable.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/orangey_red"/>
<item android:gravity="center">
<bitmap android:src="@drawable/ic_launcher"
android:gravity="center"/>
</item>
</layer-list>
I also have a theme defined for this drawable. Here is /values/style.xml
<resources>
<style name="MyCustomTheme" >
<item name="android:windowBackground">@drawable/splash_screen_drawable</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
I'm using Xamarin.Android (native), and cannot figure this problem out.
Upvotes: 1
Views: 3821
Reputation: 1443
I resolved the issue. It seems that my logo size was too big for the screen, so resizing the image to a smaller resolution was the solution to my problem.
Upvotes: 1
Reputation: 4358
The code you provided works well on my side, here is the style:
<style name="MyCustomTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
And here is the splash:
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/orangey_red"/>
<item android:gravity="center">
<bitmap android:src="@drawable/dapao"
android:gravity="center"/>
</item>
</layer-list>
I also provide my demo on github, you can compare your project with it.
Upvotes: 0