android xml drawable image on full screen background -


i need xml drawable (for cordova splash screen) in android. want display transparent logo centered on screen (without stretching), while rest of screen has background color set.

what tried first, add image in xml file:

<?xml version="1.0" encoding="utf-8"?> <bitmap     android:src="@drawable/splashscreen"     android:gravity="center_horizontal|center_vertical" /> 

this showed logo centered on screen, (obviously) has no background color.

so tried different solutions add background color xml. 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 image has background color - not full screen more. adjusts image size , gets stretched when showing full screen.

so, how can full screen drawable background color, , centered image on it?

edit: answers suggest using relativelayout - think not possible within xml file in "drawable", right? not have layout can edit - drawable gets referenced cordova.

i found solution myself:

<?xml version="1.0" encoding="utf-8"?>  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">     <item>         <color android:color="#ffff"></color>     </item>     <item>         <bitmap             android:src="@drawable/splashscreen"             android:gravity="center_horizontal|center_vertical"             />     </item> </layer-list> 

android studio shows layout still wrong - works on device expected.

to posters, suggesting adding layout-xml file: stated in question, don't have possibility that, since drawable gets included cordova. don't have control on used layout around drawable.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -