2009-12-27 93 views
1

目前我正在進行一個由標題,描述,標籤和頁腳組成的對話框。標題可以很長,在這種情況下,文本應該自動以多行顯示。描述也較長,應填寫多行。 對話框的底部必須是頁腳(如果標題和描述不能填滿整個屏幕)。 我試圖創建描述的佈局,但長文本有問題 - 如果內容很長,它不會顯示多行,但會擴展主視圖(LinearView),以便內容在可見區域上延伸。安卓版面問題

在這裏我粘貼當前狀態的打印屏幕和所需佈局的樣機: alt text http://img52.imageshack.us/img52/9697/androidscreenshot.png alt text http://img69.imageshack.us/img69/3609/screenshot20091227at716.png

TextView的「頁腳」和按鈕確定和取消應該出現在屏幕的底部,標題(「標題標題......」)和說明文字應該自動出現在多行而不是擴展父視圖中。

如果你們中的任何一個人可以給出關於解決這些佈局問題的提示,我將非常感激

謝謝!

回答

3

像這樣的東西應該有所幫助:將文本元素放在最上面,並使用weightSum將按鈕強制到佈局的底部。我不記得多線文本的非正式設置,但是如果您不使用設置爲truesingleLine屬性,那麼事情應該可以解決。

查看XML attribute documentation瞭解更多信息。

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

    <TextView 
    android:id="@id/android:title" 
    android:layout_width="fill_parent" 
    android:layout_weight="1" /> 

    <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:weightSum="2"> 
     <Button 
     android:id="@+id/btn_ok" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:text="@string/btn_ok" /> 
     <Button 
     android:id="@+id/btn_cancel"    
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:text="@string/btn_cancel" /> 
    </LinearLayout> 

</LinearLayout> 
+0

我剛剛發佈了一個類似的佈局問題,並發現這一點。在此之前,我還沒有看到weightSum屬性,但這正是我所需要的。謝謝! – Rich 2010-05-05 21:17:51