How to show the input text view in Android - android

On this screenshot:
I am looking for the solution to make the UI more decent. I like the blue line for the input box but it only show either User Name or Password only. What is the simplest way to let the 2 blue line appear below User Name and Password in order?
Cheers
Here's what i have tried so far
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/myBackground"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="#drawable/voicemeno" />
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/imageView1"
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/userNameInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/userName"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
<TextView
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/userNameInput"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/passwordInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/password"
android:ems="10"
android:inputType="textPassword"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
</RelativeLayout>

Edit:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/myBackground"
tools:context=".MainActivity"
android:selectAllOnFocus="true">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="#drawable/voicemeno" />
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/imageView1"
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/userNameInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/userName"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
<TextView
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_below="#+id/userNameInput"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/myText" />
<EditText
android:id="#+id/passwordInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_below="#+id/password"
android:ems="10"
android:inputType="textPassword"
android:textColor="#color/myText"
android:textCursorDrawable="#null" >
</EditText>
</RelativeLayout>

you can use a TextView followed by a EditText view for each of the filds(username,password) you want.

Related

How to add scrollview in linearlayout

I am implementing an registration page in which i want to implement the Scrollview. please help. Android Relative Layout Align Center i have tried this but still not getting it.
Registration.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:weightSum="1"
android:background="#f33a58"
android:baselineAligned="false"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Registration Page"
android:id="#+id/logo"
android:layout_marginTop="40dp"
android:textSize="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:textColor="#ffffff" />
<EditText
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:ems="10"
android:hint="Username"
android:layout_gravity="center"
android:textColorHint="#ffffff"
android:backgroundTint="#ffffff"
style="#style/AppTheme.PopupOverlay" />
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_gravity="center"
android:hint="Password"
android:password="true"
android:inputType="textPassword"
android:textColorHint="#ffffff"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff" />
<EditText
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_gravity="center"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColorHint="#ffffff"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff">
</EditText>
<EditText
android:id="#+id/phone_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_gravity="center"
android:hint="Phone Number"
android:inputType="phone"
android:layout_marginTop="20dp"
android:maxLength="10"
android:digits="0123456789"
android:textColorHint="#ffffff"
android:backgroundTint="#ffffff" />
<Button
android:id="#+id/register"
android:layout_width="134dp"
android:layout_height="wrap_content"
android:text="Register"
android:layout_marginTop="20dp"
android:background="#drawable/button"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:layout_marginTop="40dp"
android:text="Registration Page"
android:textColor="#ffffff"
android:textSize="35dp" />
<EditText
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_gravity="center"
android:backgroundTint="#ffffff"
android:ems="10"
android:hint="Username"
style="#style/AppTheme.PopupOverlay"
android:textColorHint="#ffffff" />
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:password="true"
android:textColorHint="#ffffff" />
<EditText
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColorHint="#ffffff" >
</EditText>
<EditText
android:id="#+id/phone_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:backgroundTint="#ffffff"
android:digits="0123456789"
android:ems="10"
android:hint="Phone Number"
android:inputType="phone"
android:maxLength="10"
android:textColorHint="#ffffff" />
<Button
android:id="#+id/register"
android:layout_width="134dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#drawable/button"
android:text="Register" />
</LinearLayout>
</ScrollView>

How to add an image into a form?

I have a simple form that ask for firstname , name and email. I would like to have a field where I can attach an image from the phone's galerie like when you send a picture through message (http://img11.hostingpics.net/pics/663614clip128.png) . Is it possible to do it ?
Here is my xml for the simple form :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="25dp"
android:layout_marginTop="25dp"
android:text="#string/m_informations"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/FirstName"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/Email"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/confirm" />
</LinearLayout>

android:background does not fill_parent or fitXY

I'm attempting to set my background image however it will not seem to fill to the edge of the screen and I'm not sure why. I'm pretty sure those two parameters have worked for me in the past.
Any suggestions are appreciated.
http://i.stack.imgur.com/WM5OJ.png
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
This is simple. first see this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
Based on your XML you set a margin on your relative layout with 20dp left and right then added a linear layout with background image that match the parent wherein the parent is the relative layout. Remove the margin of the relative layout then it will fit the screen then all of the content that needs to have a margin of 20dp left and right must be inside the linear layout to solve this.
use this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ui2"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center_vertical"
android:background="#drawable/ui2"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" >
</LinearLayout>
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textPersonName" />
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone Number"
android:inputType="textPersonName" />
<EditText
android:id="#+id/userName"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_centerInParent="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:layout_weight="0.5"
android:text="Login" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Submit" />
</RelativeLayout>
</LinearLayout>
Use padding instead of margin on your RelativeLayout as follows
android:layout_paddingLeft="20dp"
android:layout_paddingRight="20dp"
Hope this helps.
replace this
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
in your Layout to
android:paddingLeft="20dp"
android:paddingRight="20dp"
Hope this helps

i have 9 edit text for user input to take data in one activity and want to show them in the listview in another activity

i have 9 edit texts in one activity and it takes user inputs within certain time..if the user fills them within certain time i have to populate them to the listviw in another activity....and from the listview of another activity..i have to get the same edittexts ...here is the xml view of first activity...
enter code here<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="HardcodedText" >
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/editText2"
android:layout_marginRight="90dp"
android:layout_marginTop="38dp"
android:ems="10"
android:hint="2."
tools:ignore="TextFields,HardcodedText" />
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="31dp"
android:ems="10"
android:hint="3."
android:inputType="textPersonName"
tools:ignore="HardcodedText" />
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/editText4"
android:ems="10"
android:hint="5."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText6"
android:layout_marginBottom="48dp"
android:layout_toRightOf="#+id/editText6"
android:ems="10"
android:hint="4."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText6"
android:layout_alignParentLeft="true"
android:layout_marginLeft="65dp"
android:ems="10"
android:hint="6."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText5"
android:layout_alignLeft="#+id/editText7"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="7."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText8"
android:layout_below="#+id/editText3"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="8."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText2"
android:layout_alignBottom="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="43dp"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="9."
tools:ignore="TextFields" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText4"
android:layout_centerHorizontal="true"
android:text="TextView"
tools:ignore="HardcodedText" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="27dp"
android:layout_toRightOf="#+id/textView1"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="1."
tools:ignore="TextFields,HardcodedText" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:linksClickable="true"
android:text="finish" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText6"
android:layout_alignBottom="#+id/editText6"
android:layout_toLeftOf="#+id/button1"
android:text="TextView" />
</RelativeLayout>
and here is the listview activity..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="search saved session"
tools:ignore="TextFields,HardcodedText" >
<requestFocus />
</EditText>
<SearchView
android:id="#+id/searchView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/editText1"
android:layout_toRightOf="#+id/editText1"
tools:ignore="NewApi" >
</SearchView>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignLeft="#+id/editText1"
android:layout_below="#+id/searchView1" >
</ListView>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="15dp"
android:text="saved"
tools:ignore="HardcodedText" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button2"
android:layout_alignBottom="#+id/button2"
android:layout_alignRight="#+id/searchView1"
android:text="about"
tools:ignore="HardcodedText" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button1"
android:layout_alignBottom="#+id/button1"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/button1"
android:text="new session"
tools:ignore="HardcodedText" />
</RelativeLayout>

Screen is not moving up while entering text in EditText Android

When I enter text in the EditText in my emulator, the screen is not moving up so I cannot see what I am inputting.
I wanted to attach screenshots, but I don't have the required reputation yet.
This is a problem only with the following code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="#+id/recQsEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_alignRight="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="16dp"
android:ems="10"
android:maxLines="1"
android:padding="5dip"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/recAnsEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_alignRight="#+id/recQsEditText"
android:layout_below="#+id/textView2"
android:layout_marginTop="18dp"
android:ems="10"
android:maxLines="1"
android:padding="5dip"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="49dp"
android:text="#string/recoveryInfo"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/recQsEditText"
android:layout_below="#+id/recQsEditText"
android:layout_marginTop="73dp"
android:text="#string/recoveryAnsText"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/setRecQsBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/recAnsEditText"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp"
android:text="#string/saveChangesBtn" />
</RelativeLayout>
Meanwhile, it is working fine in another screen on the same app.
The working code is -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="#+id/addUserIdEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginLeft="30dp"
android:ems="10"
android:maxLines="1" />
<EditText
android:id="#+id/addTitleEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView01"
android:layout_below="#+id/TextView01"
android:ems="10"
android:maxLines="1" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/addUserIdEditText"
android:layout_below="#+id/addTitleEditText"
android:text="#string/userIdInputText"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/addUserIdEditText"
android:layout_below="#+id/addUserIdEditText"
android:text="#string/passwordInputText"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_alignParentTop="true"
android:layout_marginTop="26dp"
android:text="#string/titleInputText"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/addPasswordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView02"
android:layout_alignRight="#+id/addUserIdEditText"
android:layout_below="#+id/TextView02"
android:ems="10"
android:inputType="textPassword"
android:maxLines="1" />
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/addPasswordEditText"
android:layout_below="#+id/addPasswordEditText"
android:text="#string/loginURLinputText"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/addLoginUrlEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView03"
android:layout_below="#+id/TextView03"
android:ems="10"
android:maxLines="1" />
<EditText
android:id="#+id/addOtherNotesEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:ems="10"
android:maxLines="2" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/addLoginUrlEditText"
android:layout_below="#+id/addLoginUrlEditText"
android:text="#string/otherNotesInputText"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/addOtherNotesEditText"
android:layout_marginTop="36dp"
android:layout_toRightOf="#+id/textView2"
android:onClick="saveOnClick"
android:text="#string/saveBtn" />
</RelativeLayout>
I'm struggling to figure out why it isn't working. Please help!
In your AndroidManifest file,
add
android:windowSoftInputMode="adjustPan"
to your activity class.
example:
<activity
android:name=".YourActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan" />
This will bring editText properly adjusted to soft keyboard. check out other options in it to suit your needs.

Categories

Resources