I have a simple contact form on my Android app, it has a Name and Message field and a submit button.
The form works fine, my issue is with the layout/behaviour of the keyboard.
When the user clicks on the Name field, the keyboard pops up and they enter their name and the keyboard then displays 'Next' button, so they can move to the Message field, but then the keyboard changes to 'Enter' for a carriage return, because the android:inputType
is textMultiLine
The issue is that now the 'Submit' button is hidden behind the keyboard and the user has to hit the 'back' button to then see the submit button to submit the form.
If I change the android:inputType
from textMultiLine
to text
, the keyboard displays 'Done' which works well, but now all the text entered in the Message field is all on one line and this isn't ideal either.
The ideal solution would be for the keyboard to display the 'Next' so that I can jump to the 'Submit' button (which I do not think is possible) or for the screen to scroll up to see the 'Submit' button (or at least be scrollable).
Any ideas on how I can do this? Thank you.
Thank you.
Here is my activity_contact.xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
tools:context="com.mycompany.myapp.fragments.HomeFragment">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/bgplain"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/toplinear">
<LinearLayout
android:id="@+id/linearmenu"
android:layout_width="match_parent"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/menu"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/menu"/>
</LinearLayout>
<LinearLayout
android:layout_below="@+id/linearmenu"
android:layout_width="match_parent"
android:layout_above="@+id/tvvolume"
android:layout_height="130dp"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/lineartitle"
android:layout_below="@+id/linearmenu"
android:layout_width="match_parent"
android:layout_weight="4"
android:layout_height="120dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/logo"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_below="@+id/toplinear"
android:layout_width="match_parent"
android:paddingBottom="20dp"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:paddingRight="15dp"
android:layout_height="match_parent">
<TextView
android:text="Name"
android:textColor="#000000"
android:textSize="16sp"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/edtname"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:textSize="16sp"
android:singleLine="true"
android:inputType="textPersonName"
android:paddingLeft="10dp"
android:hint="Enter name here"
android:background="@drawable/edtback"/>
<TextView
android:text="Message"
android:textAllCaps="true"
android:textColor="#000000"
android:textSize="16sp"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/edtmessage"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="top"
android:inputType="textMultiLine"
android:padding="10dp"
android:textSize="16sp"
android:hint="Enter message here"
android:background="@drawable/edtback"/>
<Button
android:id="@+id/btnsubmit"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Submit"
android:textAllCaps="true"
android:textSize="18sp"
android:textColor="#FFFFFF"
android:background="@drawable/btnback"
android:layout_marginTop="20dp"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
Update : I've tried adding a android:imeOptions="actionNext" to the Message field, but it won't override it, presumably because it is a textMultiLine type field(?)