I searched the NET but did not find a solution to my problem. I have a form with few textViews and EditTexts. At the bottom of the screen I positioned 3 buttons. In order to fix them at the bottom of the screen I had to have them outside the scrollView as explained in How to make a static button under a ScrollView?.
However, when the soft keyboard opens as I enter text in one of the edittext, the buttons moves up to be just above the soft keyboard, covering some of edittext elements.
I want the buttons to stay at the bottom of the screen such that the softkeyboard covers them. In order to do it I have to include them in the scrollView, but then I can not position them at the bottom of the screen when the softkeyboard is closed.
Here is my 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>