仅在Android 4.0上,View1在View2.setvisibility(view.INVISIBLE)之后消失

仅在Android 4.0上,View1在View2.setvisibility(view.INVISIBLE)之后消失,android,android-asynctask,visibility,android-4.0-ice-cream-sandwich,glsurfaceview,Android,Android Asynctask,Visibility,Android 4.0 Ice Cream Sandwich,Glsurfaceview,在我的应用程序中,我有一个gametaskbar,其中包含特定的游戏控件(control_1,control_2)。另外,我有两个按钮(按钮1,按钮2),我可以切换可见性。因为我有很多UI更改,所以我在asynctask的onPostexecute()中切换可见性。 这在android 4.0之前的所有测试设备上都能很好地工作。但是>4.0设备在切换其中一个按钮的可见性时会删除“我的游戏任务栏”的背景图像。 这不应该发生,我也不知道该去哪里找 我在视图层次结构的底部有一个带有glsurfacev

在我的应用程序中,我有一个gametaskbar,其中包含特定的游戏控件(control_1,control_2)。另外,我有两个按钮(按钮1,按钮2),我可以切换可见性。因为我有很多UI更改,所以我在asynctask的onPostexecute()中切换可见性。 这在android 4.0之前的所有测试设备上都能很好地工作。但是>4.0设备在切换其中一个按钮的可见性时会删除“我的游戏任务栏”的背景图像。 这不应该发生,我也不知道该去哪里找

我在视图层次结构的底部有一个带有glsurfaceview的framelayout

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/baseframe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >

<LinearLayout
    android:id="@+id/glSurfaceHolder"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</LinearLayout>

<LinearLayout
    android:id="@+id/GameTaskbar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_gravity="bottom"
    android:background="@drawable/bar"
    android:orientation="horizontal"
    android:visibility="invisible" >

    <Button
        android:id="@+id/control_1"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="bottom"
        android:layout_margin="1dp"
        android:background="@drawable/blind" >
    </Button>

    <Button
        android:id="@+id/control_2"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="bottom"
        android:layout_margin="1dp"
        android:background="@drawable/blind" >
    </Button>   
</LinearLayout>
<Button
    android:id="@+id/Button_1"
    android:layout_width="75dp"
    android:layout_height="50dp"
    android:layout_gravity="right|center_vertical"
    android:background="@drawable/drop_64"
    android:visibility="invisible" >
</Button>

<Button
    android:id="@+id/Button_2"
    android:layout_width="75dp"
    android:layout_height="50dp"
    android:layout_gravity="left|center_vertical"
    android:background="@drawable/back_64"
    android:visibility="invisible" >
</Button>
</FrameLayout>
根据这篇文章(),我能够将Android4.0特有的不需要的行为简化为不需要的背景可视性开关

我也尝试过在按钮上使用requestFocus(),但运气不好

当我调试它时,一切看起来都应该如此,gametaskbar.getVisibility()=0。但是离开async-onPostexecute()后,背景图像消失了。在这种情况下,当我不将按钮可见性切换为不可见时,背景图像也将保持不变。就像我使用了错误的身份证,我没有

即使在模拟器中,我也可以重现这种行为

注:按钮可视性会根据需要进行更改

也许有人有主意。

修复了以下问题: 将带有游戏任务栏backgrundimage的LinearLayout更改为另一个FrameLayout,其中Imageview位于带有控件的原始LinearLayout下方

<FrameLayout
    android:id="@+id/GameTaskbar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_gravity="bottom"
    android:visibility="invisible" >

    <ImageView
        android:id="@+id/bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:src="@drawable/bar_512_2"
        android:contentDescription="@string/bar"/>

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <Button
            android:id="@+id/control_1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="bottom"
            android:layout_margin="1dp"
            android:background="@drawable/blind" >
        </Button>

        <Button
            android:id="@+id/control_2"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="bottom"
            android:layout_margin="1dp"
            android:background="@drawable/blind" >
        </Button>   
    </LinearLayout>
</FrameLayout>

奥内

<FrameLayout
    android:id="@+id/GameTaskbar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_gravity="bottom"
    android:visibility="invisible" >

    <ImageView
        android:id="@+id/bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:src="@drawable/bar_512_2"
        android:contentDescription="@string/bar"/>

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <Button
            android:id="@+id/control_1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="bottom"
            android:layout_margin="1dp"
            android:background="@drawable/blind" >
        </Button>

        <Button
            android:id="@+id/control_2"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="bottom"
            android:layout_margin="1dp"
            android:background="@drawable/blind" >
        </Button>   
    </LinearLayout>
</FrameLayout>