Android使对话框可滚动

Android使对话框可滚动,android,layout,dialog,scrollview,scrollable,Android,Layout,Dialog,Scrollview,Scrollable,当用户单击按钮时,我显示一个对话框。当对话框出现,您单击一个编辑文本输入一些文本时,您将无法再看到底部按钮(以及最低的编辑文本)。因此,您必须向下单击键盘,然后选择按钮或编辑文本。我找了一会儿答案,但找不到 那么:如何使对话框可滚动?显然,我的代码没有起作用: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

当用户单击按钮时,我显示一个对话框。当对话框出现,您单击一个编辑文本输入一些文本时,您将无法再看到底部按钮(以及最低的编辑文本)。因此,您必须向下单击键盘,然后选择按钮或编辑文本。我找了一会儿答案,但找不到

那么:如何使对话框可滚动?显然,我的代码没有起作用:

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

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:orientation="vertical"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">

<EditText         
   android:id="@+id/addKlantNaam"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/klantNaam" 
   />

<EditText         
   android:id="@+id/addKlantLocatie"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/klantLocatie" 
   />

<TextView
    android:id="@+id/scheidenDoorKomma"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    android:text="@string/scheidenDoorKomma"/>

<EditText         
   android:id="@+id/addFabrieken"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/fabrieken" 
   />

 <EditText        
   android:id="@+id/addMachines"
   android:textSize="20sp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/machines" 
   />

 <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" >

    <Button
        android:id="@+id/dialogAnnuleren"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"        
        android:text="@string/annuleren"
        android:textSize="22sp" />

    <Button
        android:id="@+id/dialogToevoegen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"   
        android:layout_toRightOf="@+id/dialogAnnuleren"     
        android:textSize="22sp"
        android:text="@string/toevoegen"/>
  </RelativeLayout>

</LinearLayout>

有人能帮我吗?

使用线性布局高度匹配\u家长。试试看它是否有效

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:orientation="vertical"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">

GeertG。。。现在我情绪化了:)试试我找到的链接。。。它可能会做的把戏,因为使用一个滚动视图与一个以上的孩子…我不知道它是否解决了你的问题,但。。。

这些解决方案应该像创建一个包含多个子元素的scrollview一样工作。。。它能解决你的问题吗?IDK

也注意


但是关闭并重新打开键盘对我来说是合理的。。。不要在上面停留太久:)

你所要求的准则是。如你所见。有很多方法可以达到你的要求

此外,您可以考虑更改键盘上的“输入”按钮的默认动作,以选择下一个EditText,并最终在您完成时提交表单():


据我所知,没有办法使对话框或活动可滚动。。。只是一个类似listview或scrollview的视图…所以你的选择是以不同的方式排列视图,或者创建一个在按下外部键时关闭键盘的对焦更改,但是获取键盘将始终阻止部分界面。。。或者以不同的方式或更小的尺寸排列。顺便说一句,你应该使用换行内容或匹配父对象,而不是填充父对象啊,这很遗憾:p我的应用程序将在不同的尺寸上运行,所以我不想给对话框一个预定义的高度。所以我想实际上我唯一的选择就是编辑键盘,让用户在按enter键时进入下一个编辑文本?因为不断地关闭和打开键盘对我来说似乎很烦人。在scrollview或lineairlayout中?据我所知,scrollview中只有一个孩子…所以我认为这不是一个解决方案…如果你想,我将向你展示我是如何使用我的键盘的…但是你也应该知道不同的设备需要不同的分辨率,所以几乎可以肯定的是你必须更改xlarge大型或正常尺寸设备的DIM…并且不要给它预定义的高度。。。缩放内容您应该始终尝试使用换行内容或匹配父对象谢谢您的回复。我尝试过,但它不起作用:(当我将其更改为匹配父项(此LinearLayout应使用android:layout\u height=“wrap\u content”)时,它也会发出警告,然后尝试使用fill\u parent。android:scrollbars=“vertical”,将此行放在ScrollView标记中。抱歉,也不起作用(尝试使用wrap\u content和匹配\u parent)哈哈,谢谢;)我尝试过这些链接,但我想简单的事实是这是不可能的。我将使用android:imeOptions=“actionDone”和android:singleLine=“true”使键盘在回车时隐藏。你说得对,我会接受这样一个事实:键盘会掉下来然后弹出;)谢谢你的帮助。我希望这是你将要面对的最大问题:)不是一个大问题。。。希望我能帮忙:)
<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:orientation="vertical"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">
android:imeOptions="actionDone"