2012-03-04 16 views
10

私はグロスフェイスをフルスクリーンで使用しています。ボタンをクリックすると別のレイアウトが表示されます(設定タイプのもの)。オーバーレイが表示されている状態から始めれば、私はそれを不可視にしてからもう一度問題なく表示することができます。しかし、私がそれを目に見えないものから始めると、私はそれを再び見ることができません。コードは次のとおりです:最初にインビジブルに設定されていればアンドロイドセットのビジビリティは表示されません

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

    <android.opengl.GLSurfaceView 
    android:id="@+id/glPlaySurface" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
</android.opengl.GLSurfaceView> 

<RadioGroup 
    android:id="@+id/radioGroup1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:orientation="horizontal" > 

    <RadioButton 
     android:id="@+id/btnRotate" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:checked="true" 
     android:text="R" 
     android:textColor="#000" /> 

    <RadioButton 
     android:id="@+id/btnPan" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dp" 
     android:text="P" 
     android:textColor="#000" /> 
</RadioGroup> 

<Button 
    android:id="@+id/btnLights" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_marginLeft="15dp" 
    android:layout_toRightOf="@+id/radioGroup1" 
    android:text="Lights" /> 

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layoutLights" 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    android:visibility="visible" <--- Does not work if set to invisible 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 

    android:background="#fff" > 

    <Button 
    android:id="@+id/btnLightsOK" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_marginLeft="15dp" 
    android:text="OK" /> 

    <Button 
    android:id="@+id/btnLights" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_marginLeft="15dp" 
    android:text="OK" /> 

</RelativeLayout> 

</RelativeLayout> 


private OnClickListener mOnLightsClick = new OnClickListener() { 
    public void onClick(View arg0) { 
     if(mLayoutLights.getVisibility() == View.VISIBLE) { 
      mLayoutLights.setVisibility(View.INVISIBLE); 
     } 
     else { 
      mLayoutLights.setVisibility(View.VISIBLE); 
     } 
    } 
}; 
+0

問題はglsurfaceに関連しています。 glsurfaceを通常のサーフェイスビューに置き換えるとうまくいきます。 – user1248322

+0

詳細情報:グランスサーフェスをGONEに設定した場合、レイアウトをVISIBLEに設定し、グラスサーフェスをVISIBLEに戻します。しかし、... gloneをGONEの代わりにINVISIBLEに設定すると、うまくいきません。 – user1248322

+0

ok - apiデモのsurface_view_overlayは、私が探しているものとまったく同じです - 私はどこが間違っていたのか分かります。 – user1248322

答えて

10

でframeLayoutでsurfaceViewラッピングビュー

  • にBringToFront関数を呼び出す
  • (これは#2に関連しているが、それはまだ助けるかもしれないが)、それを手に入れました。レイアウトだけでなく、レイアウト内のすべてのアイテムの表示を設定する必要があります。したがって、このコードは働いた:

    if (mLayoutLights.getVisibility() == View.VISIBLE) { 
        ((Button) findViewById(R.id.btnLightsOK)).setVisibility(View.GONE); 
    ((Button) findViewById(R.id.btnLightsCnc)).setVisibility(View.GONE); 
    mLayoutLights.setVisibility(View.GONE); 
    } else { 
        mLayoutLights.setVisibility(View.VISIBLE); 
    ((Button) findViewById(R.id.btnLightsOK)).setVisibility(View.VISIBLE); 
    ((Button) findViewById(R.id.btnLightsCnc)).setVisibility(View.VISIBLE); 
    } 
    
  • +1

    ありがとう、私も同じ問題がありました。 – Enrichman

    1

    私は3つの独立したものを試してみることをお勧めします。

    1. レイアウトの幅と高さを変更してコンテンツをラップすると、親と一致する問題が発生する可能性があります。
    +0

    ありがとう - しかし、それらの違いはありませんでした。 – user1248322

    +0

    レンダリングスレッドが実行中であるか、表面上で起動しているかどうかは分かりますか? – BeatingToADifferentRobot

    +0

    はい - 3dがタッチして適切にレンダリングします(私は連続レンダリングとダーティーレンダリングの両方を試しましたが、違いはありません) – user1248322

    -3
    case R.id.title_call_button: 
    if(llButtonCallNow.getVisibility() != View.VISIBLE){ 
    llButtonCallNow.setVisibility(View.VISIBLE); 
    } 
        else{ 
        llButtonCallNow.setVisibility(View.GONE); 
        Toast.makeText(getBaseContext(), ("Im here baby :)"), 
        Toast.LENGTH_SHORT).show(); 
    
        } 
    break; 
    
    14

    は、同様のエラーが発生しましたが、それはUiThreadを使用していない私の愚かな間違いによるものでした。私の場合は

    Activity act = (Activity)context; 
    act.runOnUiThread(new Runnable(){ 
    @Override 
    public void run() { 
        mLayoutLights.setVisibility(View.VISIBLE); 
    } }); 
    
    +1

    ありがとう、それは私の問題を解決!私はコールバックで可視性を設定していましたが、ビューがすぐには更新されなかった理由は分かりませんでしたが、現在は機能しています。 UIスレッドで作業する必要があるようです。 – Jack

    2

    、平野SurfaceViewで、私は、XML、ないINVISIBLEにGONEへの表示を設定します。その後、私はそれを正しく設定することができます。

    +0

    これは私の問題を解決しました!ありがとう! :) – acegs

    -2

    プロパティの幅と高さを "match_parent"ではなく "fill_parent"に設定するだけです。すべての子要素の表示を設定する必要はありませんが、上位レベルのコンテナ/要素のみに設定する必要はありません。

    関連する問題