0

в моей APP Я получил гаметную панель, которая содержит определенные gamecontrols (control_1, control_2). Кроме того, у меня есть две кнопки (Button_1, Button_2), где я могу переключать видимость. Поскольку у меня много UI-изменений, я делаю эту видимость-переключение в onPostexecute() для асинтезы. Это хорошо работает на всех проверенных устройствах, предшествующих Android 4.0. Но> 4.0 устройства удаляют фоновое изображение моей панели гаметы при переключении видимости одной из кнопок. Этого не должно произойти, и у меня нет больше идей, куда искать.View1 исчезает после View2.setvisibility (view.INVISIBLE) только на Android 4.0

У меня есть framelayout с glsurfaceview в нижней части иерархии представлений.

<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> 

это часть, где переключатель visibilty:

protected void onPostExecute() { 
if(button_1_state){ 
    Button_1.setVisibility(View.VISIBLE); 
} 
else{ 
    Button_1.setVisibility(View.INVISIBLE); 
} 
if(button_2_state){ 
    Button_2.setVisibility(View.VISIBLE); 
} 
else{ 
    Button_2.setVisibility(View.INVISIBLE); 
} 

... 
} 

Согласно этому сообщению (Error when refreshing View on top of SurfaceView) я был в состоянии снизить удельный нежелательное поведение Android4.0 к нежелательным backgroundvisibilityswitch.

Я также попробовал requestFocus() на кнопках без везения.

Когда я отлаживаю его, все выглядит так, как надо, и gametaskbar.getVisibility() = 0. Но после выхода из async-onPostexecute() исчезнет фоновое изображение. Когда в этой ситуации я не переключу кнопку на невидимость, будет также оставаться фоновое изображение. Как я использую неправильные идентификаторы, которых у меня нет.

Даже в эмуляторе я могу воспроизвести это поведение.

пс: изменения buttonvisibility, как хотелось

Может быть кто-то есть идея.

ответ

0

зафиксировал это: изменилось LinearLayout с backgrundimage от GameTaskBar к другому 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> 

ornay