我有一个占用全屏的gsurface。点击一个按钮后,我希望显示另一个布局(设置类型的东西)。如果我首先看到叠加层,那么我可以将其隐藏起来,然后再次可见并没有问题。但是如果我从无形开始,我不能再让它看不见。代码如下:如果最初设置为不可见,则android setVisibility不会显示
<?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);
}
}
};
问题与glsurface有关。如果我用普通的surfaceview替换glsurface,它可以正常工作。 – user1248322 2012-03-04 19:18:00
更多信息:如果我将glsurface设置为GONE,将布局设置为VISIBLE,然后将glsurface设置为VISIBLE - 它可以工作。但是...如果我将表面设置为INVISIBLE而不是GONE - 它不起作用。 – user1248322 2012-03-05 00:22:35
好的 - api演示中的surface_view_overlay完全符合我的要求 - 我会看到我出错的地方,然后发布。 – user1248322 2012-03-05 01:19:32