在引用SurfaceView的Activity里面写了禁用home键的操作  
public void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
    }  然后布局就不显示了!
注释掉onAttachedToWindow() 之后布局显示正常!
有哪位大神知道是什么原因么?

解决方案 »

  1.   

    布局是这样子的
     <include layout="@layout/scanner_toolbar"/>    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">        <SurfaceView
                android:id="@+id/scanner_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"/>        <com.google.zxing.view.ViewfinderView
                android:id="@+id/viewfinder_content"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:corner_color="@color/corner_color"
                app:frame_color="@color/viewfinder_frame"
                app:label_text="二维码/条形码扫描"
                app:label_text_color="@color/colorAccent"
                app:laser_color="@color/laser_color"
                app:mask_color="@color/viewfinder_mask"
                app:result_color="@color/result_view"
                app:result_point_color="@color/result_point_color"/>    </FrameLayout>
    根据网上的说法加了 surfaceView.setZOrderOnTop(true);
            surfaceView.setZOrderMediaOverlay(true);也不行。
      

  2.   

    把super那行去掉试试;