1

我有一个表面视图,我在上面放了一个相机预览。最重要的是,我有一个包含一堆视图的相对布局,例如扫描按钮等。

我正在尝试使这些视图之一不可见,就像这样

myIcon.setVisibility(View.INVISIBLE);

而且我也试过

myIcon.setVisibility(View.GONE);

两者似乎都不起作用。Invisible 根本不起作用,而且 Gone有点用

在这里您可以看到一个 2D 图标,一个设置按钮。在隐藏之前,它看起来像这样:

初始

然后我调用 setVisibility(View.GONE)

在此处输入图像描述

您可以清楚地看到保存这些视图的线性布局通过为设置按钮提供更多空间来做出响应,但它并没有从其后面移除 2D。我认为这与 SurfaceView 有关,因为我知道这通常会起作用。

我努力了

myIcon.requestFocus();

在我改变可见性之后,但仍然没有。

有什么建议么?请仅在您对此特定问题有经验的情况下回复

编辑:这是我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.sample.SampleJavaCameraView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:visibility="gone"
    android:id="@+id/cv_surface_view" />






<LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true">
    

  
  
<ImageView 
    android:id="@+id/myIcon"
    android:layout_width="30dip"
    android:layout_height="30dip"
    android:src="@drawable/twod_icon"
    
    />

    <ImageButton 
    android:id="@+id/settingsBtn"
    android:layout_width="30dip"
    android:layout_height="30dip"
    android:src="@drawable/settings_gear"
    android:background="@null"
    />
</LinearLayout>


  <ImageButton
      android:id="@+id/scan_btn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/logo_small"
      android:background="@drawable/blue_radial_grad"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:padding="20dip"
       />
  

在这里,您可以看到我试图隐藏的图像被包裹在线性布局中。SurfaceView 在顶部,它是 SurfaceView 的 OpenCV 包装类

4

1 回答 1

2

也许试试myIcon.bringToFront();

于 2013-04-25T20:12:47.537 回答