开发者

XML layout does not show correctly

I'm really having a hard time trying to figure out what's going on here. I have this xml file describing a layout:

<?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_开发者_如何学Cplay"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_marginTop="5px" 
                style="?android:attr/buttonStyleSmall"
                android:src="@drawable/button_pause" />
</LinearLayout>

But when it comes to get drawn, it just shows an empty black screen. I call setContentView in my activity. Actually, I've found out that if I remove the SurfaceView tag, it gets drawn correctly.

Can anyone help me out to know what's happening? Thanks

Edit: Thanks to the answers, I've found out that the SurfaceView is taking all the space so the buttons are not visible. Any ideas on how can I avoid that? Thanks


Try changing the SurfaceView to:

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

This will cause it to fill only the available height unused by the other views in the linear layout.


Please refer http://developer.android.com/guide/topics/graphics/index.html it may help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜