2011-12-29 35 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