Search code examples
androidimageviewandroid-custom-viewwallpaper

ImageView wallpaper inside custom view is not showing up on some devices


I currently have the following XML code for my custom view:

<com.pink.jazz.RootView
    android:id="@+id/rootView"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingStart="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingEnd="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MouseActivity" >

    <ImageView
        android:id="@+id/mouse_hole"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/mouse_hole"
        android:visibility="gone"
    />
</com.pink.jazz.RootView>

On some devices (such as the Samsung Galaxy Tab 4), the wallpaper image mouse_hole shows fine, while it does not appear at all on other devices such as the Asus Transformer Infinity TF700T. The visibility of mouse_hole is being changed to visible programmatically when I start my game. My custom view extends RelativeLayout.

Could anyone know what is wrong here?


Solution

  • I had the similar problem. Try to put your image mouse_hole in every forder for different screen sizes:

    drawable-hdpi

    drawable-ldpi

    drawable-mdpi

    drawable-xhdpi

    drawable-xxhdpi

    drawable-xxxhdpi