我搜索了NET,但没有找到解决我的问题的方法。我有一个几个textViews和EditTexts的形式。在屏幕的底部,我定位了3个按钮。为了解决它们在屏幕的底部,我必须让它们在scrollView之外,如How to make a static button under a ScrollView?中所解释的。如何在scrollView的底部设置按钮,使按钮被软键盘覆盖
但是,当我在其中一个编辑文本中输入文本时,软键盘打开时,按钮向上移动到软键盘上方,覆盖一些edittext元素。
我希望按钮保持在屏幕的底部,使软键盘覆盖它们。为了做到这一点,我必须将它们包含在scrollView中,但是当软键盘关闭时,我无法将它们放置在屏幕的底部。
这里是我的XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bgcolor"
android:orientation="vertical"
android:paddingTop="5dp">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:id="@+id/list_title2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="@string/xml_text_text"
android:textColor="@color/textColor"
android:visibility="gone" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:gravity="center"
android:padding="10dp"
android:text="@string/category_adding"
android:textColor="@color/myColor"
android:textSize="18sp"
android:textStyle="bold" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:isScrollContainer="true"
android:orientation="vertical"
android:visibility="visible">
<RelativeLayout
android:id="@+id/categoryLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:id="@+id/categoryQuestionNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/category_add_question_number"
android:textColor="@color/myColor"
android:textSize="18sp" />
<talkie.feedback.NumberPickerHorizontal
android:id="@+id/horizontal_number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" />
<android.support.design.widget.TextInputLayout
android:id="@+id/questionPromptWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/categoryQuestionNumber"
android:layout_marginTop="2dp"
android:hint="@string/category_add_question">
<android.support.design.widget.TextInputEditText
android:id="@+id/questionPrompt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/user"
android:drawableStart="@drawable/user"
android:ems="45"
android:imeOptions="actionNext"
android:singleLine="true"
android:textColor="@color/myColor"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/questionExplanationWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/questionPromptWrapper"
android:layout_marginTop="2dp"
android:hint="@string/category_add_explanation">
<android.support.design.widget.TextInputEditText
android:id="@+id/questionExplanation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/user"
android:drawableStart="@drawable/user"
android:ems="45"
android:imeOptions="actionDone"
android:singleLine="true"
android:textColor="@color/myColor"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/add"
android:layout_width="130dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/questionExplanationWrapper"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:background="@drawable/border_round_corners_thin_mycolor_bkg"
android:text="@string/category_add_add_question"
android:textColor="@color/simple_white"
android:textSize="13sp"
android:textStyle="bold" />
<Button
android:id="@+id/delete"
android:layout_width="130dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/questionExplanationWrapper"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/border_round_corners_thin_mycolor_bkg"
android:text="@string/category_add_delete_question"
android:textColor="@color/simple_white"
android:textSize="13sp"
android:textStyle="bold" />
<RelativeLayout
android:id="@+id/categoryLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/delete"
android:layout_marginTop="2dp"
android:background="@drawable/border_round_corners_thin_blue"
android:padding="10dp"
android:visibility="visible">
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/categoryLayout2"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="3">
<Button
android:id="@+id/save2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@drawable/btn_background"
android:text="@string/save_action"
android:textAllCaps="false"
android:textColor="@color/simple_white" />
<Button
android:id="@+id/return2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:background="@drawable/btn_background_blue"
android:text="@string/category_add_category"
android:textColor="@color/simple_white"
android:textStyle="bold" />
<Button
android:id="@+id/exit2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:background="@drawable/btn_background_exit"
android:text="@string/register_return"
android:textAllCaps="false"
android:textColor="@color/simple_white" />
</LinearLayout>
</LinearLayout>
在您的清单中,有问题的活动,用'机器人:windowSoftInputMode =” adjustPan“' –
是的,它做到了。但我读过adjustPan相比adjustResize可能导致问题的地方。你能详细说明一下吗? – Zvi
我在我的应用程序中使用adjustPan的原因与您描述的完全相同,并且没有问题。你能否详细说明_“我在某处调整潘可以导致问题”_?你在哪里读到这个?什么问题的王? –