2010-07-13 68 views
1

我需要有一個視頻預覽(於表面的)和一個TextView和幾個按鈕(在屏幕的底部)GUI預覽和按鈕一起

目前,我的預覽的身高大,但它的窄並在屏幕最左邊,TextView不可見。

按鈕放在我需要的底部。

如何使預覽的寬度變大以及TextView可見?

這裏是我的佈局:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
> 
<TextView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Android Recorder" 
/> 
<SurfaceView android:id="@+id/camsurface"  
android:layout_width="fill_parent" 
android:layout_height="0px" 
android:layout_weight="1" /> 

<TextView 
android:id="@+id/recording_time" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text=" 00:00" 
/> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
> 

<Button android:id="@+id/btn_settings" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Settings"/> 

<Button android:id="@+id/btn_record" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Record" /> 

回答

1

您「預覽非常小」是非常小的,因爲你必須把它設置爲140px廣場,在佈局硬連線。

要麼利用android:layout_weightLinearLayout,或使用RelativeLayout,讓儘可能提供您SurfaceView採取儘可能多的空間。

例如,這裏是具有一個Button在底部和一個WebView佈局填滿所有剩餘空間:

<?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" 
    > 
    <WebView android:id="@+id/webkit" 
     android:layout_width="fill_parent" 
     android:layout_height="0px" 
     android:layout_weight="1" 
    /> 
    <Button android:id="@+id/helpcast" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="View Helpcast" 
    /> 
</LinearLayout> 
+0

謝謝。你能解釋一下重量屬性嗎?我不明白文件是如何解釋它的。 – Namratha 2010-07-14 09:07:38

+0

我如你所說設置了Surface View的高度和重量屬性,但請參閱上面的問題。 – Namratha 2010-07-14 09:17:07

+0

問題已解決,但請解釋重量屬性 – Namratha 2010-07-14 10:06:58

0

修正:

<?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" 

機器人:layout_height = 「FILL_PARENT」