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

2

6

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?

Mestee answered 24/12, 2015 at 19:1 Comment(6)
This Asus-tablet designed to punish people. It's not the first its issue. Saying that, can you post code which is switching Visibility of the mouse_hole?Holleyholli
How big is the mouse_hole drawable?Maigre
Re: Scana Actual size is 1920x1200, but I tried converting it into a Bitmap (to save memory) and scaling it to 1280x800, and it still doesn't display.Mestee
can post some code to get more idea ?Bramwell
did you try using a relative layout, and does it work with it? then the error is in your layout. you should provide your custom layout and the code where you change visibility.Hence
did you solved this ?Sestet
A
0

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

Ambrosane answered 3/1, 2016 at 17:17 Comment(0)
A
0

Could be that the layout isn't being updated properly. I'd suggest using the HierarchyViewer to check on the size and positioning of the missing view on the Asus Transformer Infinity. Here are the steps you likely have to do for getting the Hierarchy Viewer to work with the Asus:

  1. Make sure you are debugging on the Asus
  2. Add the ViewServer Jar to your project.
  3. Temporarily add the library calls to make your app available to the Hierarchy Viewer, sample code can be seen here
  4. Open the Hierarchy Viewer. In android studio that is Tools Menu > Android Sub Menu > Android Device Monitor
  5. Make sure you are in the Hierarchy View Perspective
  6. Select the app you are running(it might take a bit for the layout to show up)
  7. Use the tree node pane to find the missing view
  8. Select the view by clicking on it, use the View Properties tab to verify that the measured size(found under the measure property section) for the width and height are greater than 0
  9. Verify that the view is placed with in the parent view bounds by looking at the layout property section(mLeft, mTop, mRight, mBottom), here is a link to someone looking at the layout properties(though he is tracking down a performance problem).
Alcantar answered 4/1, 2016 at 13:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.