Search code examples
androidglsurfaceview

Android screen rendered really wrong


I'm using a GLSurfaceView to render a live wallpaper behind my apps interface which consists of android UI elements.

In the beginning of my app I ask the user if they would like to see this wallpaper or not. ONLY if the user accepts the GLSurfaceView is inflated in the existing xml as a first element so it will stay behind.

My problem is exactly the opposite of what i would think it would.

When the wallpaper is ACTIVATED the screen renders properly, like so:

enter image description here

When I don't use the wallpaper it's rendered like a, partially burned graphic card:

enter image description here

As you see from the xml structure, my GLSurfaceView is not even injected in the problematic case.

Something weird is that when it's injected the DDMS Monitor displays it as just

If the opposite was the case it would be clear that the problem is caused by the GLSurfaceView. But now it seems as if the lack of it causes this problem.

Any ideas on what could be the problem?

I'm using Nexus 4 to test and it seems that it could be related based on DanJAB

XML layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

  <Button
    style="?metaButtonBarButtonStyle"
    android:id="@+id/home_history"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@+id/button_calibrator"
    android:text="@string/history"/>

  <View
    android:id="@+id/button_calibrator"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/home_history"
    android:layout_alignBottom="@+id/home_history"
    android:layout_centerHorizontal="true"/>

  <Button
    style="?metaButtonBarButtonStyle"
    android:id="@+id/home_help"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_toRightOf="@+id/button_calibrator"
    android:text="@string/help"/>

  <View
    android:id="@+id/screen_menu_seperator"
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:layout_below="@+id/home_history"
    android:background="@color/holo_blue"/>

  <ListView
    android:id="@+id/homescreen_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/screen_menu_seperator"
    android:background="@android:color/transparent"
    android:cacheColorHint="@android:color/transparent"/>

  <View
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:layout_alignParentBottom="true"
    android:background="@color/holo_blue"/>

</RelativeLayout>

GLSurfaceView XML:

<?xml version="1.0" encoding="utf-8"?>
<android.opengl.GLSurfaceView    xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/background"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_centerInParent="true"
  android:visibility="gone"/>

and in java:

getLayoutInflater().inflate(R.layout.background, contents);
GLSurfaceView background = (GLSurfaceView) contents.findViewById(R.id.background);

Solution

  • This is a phone bug. Nexus 4 causes this issue with certain theme configurations.