1

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.

1
  • 9-patch images is not suitable for this case. I am not sure what do you mean about won't center my image neatly in the center, I think it is better to give a picture for you result and what do you want to get. Commented Jun 18, 2018 at 9:06

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.