2011-12-29 87 views
0

這是我一直在處理的自定義警報對話框的佈局。這只是一個TextView與下方的複選框:佈局中的元素沒有出現(被另一個元素掩蓋)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<ScrollView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/help_dialog_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="20dp" /> 
</ScrollView> 

<CheckBox 
    android:id="@+id/display_help_dialogs_checkbox" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:text="@string/display_help_dialogs" /> 

當TextView中的TEXTSIZE足夠大時(即當滾動型實際上是「投入使用」),該複選框無處可看。

感謝您的幫助, 米切爾

+0

只是在另一個滾動視圖中包裝整個上面的代碼。 – Urban 2011-12-29 16:03:21

+0

@Urban:嗯......我很好奇scrollview如何處理其中包含的另一個滾動視圖。 – DeeV 2011-12-29 16:13:54

+0

oh right..hmm ...來想一想,現在即使我好奇... – Urban 2011-12-29 19:17:43

回答

2

我相信你ScrollView是推動佈局的邊界之外的Checkbox。嘗試是這樣的:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/help_dialog_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="20dp" /> 

    <CheckBox 
     android:id="@+id/display_help_dialogs_checkbox" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/display_help_dialogs" /> 
    </LinearLayout> 
</ScrollView> 

您可能需要在這種情況下,指定滾動視圖的尺寸,但什麼應該發生的是LinearLayout變得比ScrollView指定的區域更大。然後,ScrollView將允許用戶向下滾動佈局以查看其餘部分。

+0

完美。我最初試圖將TextView和CheckBox都放到ScrollView中,但ScrollView只能有一個孩子......所以我放棄了併發布了這個問題。當然,解決方案非常簡單! – MitchellSalad 2011-12-29 16:06:52