I need xml drawable (for splash screen for cordova) in android. I want to display a transparent logo in the center of the screen (without stretching), and the background color is set on the rest of the screen.
At first I tried to add only the image to the xml file:
<?xml version="1.0" encoding="utf-8"?> <bitmap android:src="@drawable/splashscreen" android:gravity="center_horizontal|center_vertical" />
This showed a logo centered on the screen, but (obviously) has no background color.
So, I tried different solutions to add background color to this xml. For example:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <solid android:color="#FFFFFF" /> </shape> </item> <item> <bitmap android:src="@drawable/splashscreen" android:gravity="center_horizontal|center_vertical" /> </item> </layer-list>
Now the image has a background color - but this is no longer a full screen. It adjusts to image size and stretches when displayed in full screen.
So, how can I get a full screen with a background color and a centered image on it?
EDIT: All answers suggest using RelativeLayout - but I think this is not possible in the XML file in "drawable", right? I donβt have any layout that I can edit - only with the drawing ability referenced by the cordova.
android xml drawable
Raalf
source share