Tôi có một glsurface chiếm toàn màn hình. Tại một nút bấm, tôi muốn bố cục khác xuất hiện (loại cài đặt của sự vật). Nếu tôi bắt đầu với lớp phủ có thể nhìn thấy, tôi có thể làm cho nó vô hình và sau đó có thể nhìn thấy một lần nữa mà không có vấn đề gì. Nhưng nếu tôi bắt đầu với nó vô hình, tôi không thể làm cho nó bao giờ có thể nhìn thấy một lần nữa. Mã sau:android setVisibility không hiển thị nếu ban đầu được đặt thành invisble
<?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);
}
}
};
sự cố liên quan đến glsurface. Nếu tôi thay thế các glsurface với một surfaceview bình thường nó hoạt động tốt. – user1248322
thông tin thêm: nếu tôi đặt glsurface thành GONE, đặt bố cục thành VISIBLE, sau đó đặt glsurface trở lại thành VISIBLE - nó hoạt động. Nhưng ... nếu tôi đặt glsurface thành INVISIBLE thay vì GONE - nó không hoạt động. – user1248322
ok - surface_view_overlay trong bản demo api thực hiện chính xác những gì tôi đang tìm kiếm - tôi sẽ thấy nơi tôi đã đi sai và sau đó đăng bài. – user1248322