0

I am working on an Android project and I chose vector drawables, it runs fine for all versions. However, on some devices (Wiko Ridge 1280*720, ~ 294 dpi running on KitKat (4.4) in my case ), the image is stretched to fullscreen. What I'm doing is creating an xml drawable:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <color android:color="#FFFFFF"></color>
    </item>
    <item
        android:gravity="center"
        android:width="210dp"
        android:height="90dp"
        android:bottom="80dp"
        android:drawable="@drawable/logo_app" />
</layer-list>

*@drawable/logo_app is the vector.

That I'm setting as window background of the SplashActivity:

<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_bg</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
</style>

I tried many solutions, such as:

  • using png instead of vector
  • creating a specific drawable background for devices under api 21

But nothing seems to solve the problem.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Belbahar Raouf
  • 760
  • 1
  • 4
  • 17
  • see `android.graphics.drawable.LayerDrawable` javadocs and check when `android:height` and `android:width` were introduced – pskink Jul 16 '18 at 16:42
  • I think OP knows that these attributes aren't supported in API < 23, he's looking for a replacement I guess. – Rafik Tighilt Jul 16 '18 at 16:44
  • I already tried to replace width and height attributes according to this answer :https://stackoverflow.com/questions/42885410/vector-drawable-in-layer-list-on-older-android-versions – Belbahar Raouf Jul 16 '18 at 16:53
  • @BelbaharRaouf could You download and install this app from Google Play and paste screenshot with display resolution information? - https://play.google.com/store/apps/details?id=com.nomone.resolution_changer – deadfish Jul 16 '18 at 18:58
  • @deadfish, i'm using emulator so i can emulate any resolution i want. – Belbahar Raouf Jul 17 '18 at 13:32
  • @pskink to avoid blanck/transparent screen on some devices. – Belbahar Raouf Jul 17 '18 at 13:44
  • ActivityManager usually has some time lag between the click on the app icon and actually calling the onCreate() (so inflating the layout) in the target activity. So, In order not to annoy user with the UI unresponsiveness using window background is the prefered way. – Belbahar Raouf Jul 17 '18 at 13:57
  • DrawableWrapper requires API level 23. And i already tried setting backgroundDrawable from activity. it doesn't resolve the problem. – Belbahar Raouf Jul 17 '18 at 14:30

0 Answers0