Android XML布局未正确显示

Android XML布局未正确显示,android,android-layout,surfaceview,Android,Android Layout,Surfaceview,我真的很难弄清楚这里发生了什么。我有一个描述布局的xml文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height

我真的很难弄清楚这里发生了什么。我有一个描述布局的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" 
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">

   <SurfaceView android:id="@+id/surface"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center">
    </SurfaceView>

   <TextView android:id="@+id/text_kb_streamed"
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content"
             android:textStyle="bold" 
             android:text="Streaming .mp3 Audio Tutorial" />

   <ProgressBar android:id="@+id/progress_bar"
                android:layout_width="200px" 
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                style="?android:attr/progressBarStyleHorizontal"/>

   <ImageButton android:id="@+id/button_play"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_marginTop="5px" 
                style="?android:attr/buttonStyleSmall"
                android:src="@drawable/button_pause" />
</LinearLayout>
但是当它被画出来的时候,它只是显示一个空的黑屏。我在活动中调用setContentView。事实上,我发现如果我删除SurfaceView标记,它就会正确绘制

有人能帮我弄清楚发生了什么事吗? 谢谢

编辑:多亏了这些答案,我发现SurfaceView占据了所有空间,所以按钮不可见。有什么办法可以避免吗? 谢谢

请参考
它可能会对您有所帮助。

尝试将SurfaceView更改为:

   <SurfaceView android:id="@+id/surface"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center">
</SurfaceView>

这将导致它只填充线性布局中其他视图未使用的可用高度。

我从未使用过SurfaceView,它是否有任何环绕的内在尺寸?看起来它占用了所有的空间。我会尝试给它一些固定的小高度,比如20px。你有没有碰巧把setZOrderOnTop设置为true?@bigstones没错,如果我把它设置为20px,其余的就会显示出来。因此,它肯定会占用所有的时间space@NickCampion我不使用AFAK函数,除非它是自动调用的