Screen is not moving up while entering text in EditText Android - 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.

Related

ScrollView not Working in my relativelayout

I followed someone example on having a relative layout with a scrollview. I did exactly it and my page still won't scroll. Am I missing out something? Or must I change it to a linear layout to make it work? Still new to Android Studio here.
Any help will be much appreciated. Randomly adding words so I can post this.
activity_info.xml
<?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="fill_parent"
android:layout_height="900dp"
tools:context="mapp.com.sg.receiptscanner.Info">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="900dp"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="900dp"
>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/editText5"
android:layout_marginTop="13dp"
android:text="Name of Product:"
android:textColor="#android:color/black"
android:textSize="18sp"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="16dp" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText6"
android:layout_below="#+id/editText5"
android:layout_marginTop="16dp"
android:text="Company:"
android:textColor="#android:color/black"
android:textSize="18sp"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="16dp" />
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText5"
android:layout_below="#+id/textView9"
android:ems="10"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="61dp" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView8"
android:layout_marginStart="13dp"
android:ems="10"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="61dp" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText6"
android:layout_below="#+id/editText6"
android:layout_marginTop="22dp"
android:textSize="18sp" />
<EditText
android:id="#+id/editText8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView11"
android:layout_below="#+id/textView12"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editText6"
android:layout_marginTop="11dp"
android:layout_toEndOf="#+id/textView11"
android:text="Receipt Number:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText8"
android:layout_below="#+id/editText8"
android:layout_marginTop="19dp"
android:text="Start Date of Warranty:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="12dp"
android:layout_marginTop="273dp"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText10"
android:layout_alignTop="#+id/editText10"
android:layout_marginTop="60dp"
android:text="Expiry Date of Warranty:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView14"
android:layout_below="#+id/textView14"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText11"
android:layout_below="#+id/editText11"
android:layout_marginTop="14dp"
android:text="Bought from:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView15"
android:layout_below="#+id/textView15"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/editText12"
android:layout_below="#+id/editText10"
android:layout_marginTop="177dp"
android:text="Warranty Site:"
android:textColor="#android:color/black"
android:textSize="18sp" />
<EditText
android:id="#+id/editText14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textView16"
android:layout_below="#+id/textView16"
android:ems="10"
android:inputType="textPersonName" />
</RelativeLayout>
</ScrollView>
We can able to scroll the view only when the items in the scroll view exits the visibility. I check your code it happens for your layout too. For checking add few more item in that scroll view, It will start scroll
And one more thing instead of setting some constant value set android:layout_height="wrap_content"
This should work:
<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:context="mapp.com.sg.receiptscanner.Info">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
always use this
android:layout_width="match_parent"
android:layout_height="wrap_content"
for scrollview and its only child.

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>

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>

How to show the input text view in 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.

How to resize my xml so that it will fit nicely on the emulator

I am currently having trouble with my GUI design because of the whole page will be shifted to the right and become like this:
create_events.xml
<?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"
android:background="#color/crimson"
android:orientation="vertical" >
<TextView
android:id="#+id/txtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="#android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/txtDate"
android:layout_below="#+id/txtDate"
android:layout_marginTop="16dp"
android:text="Title:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#android:id/text1"
android:layout_alignBottom="#android:id/text1"
android:layout_marginLeft="34dp"
android:layout_toRightOf="#android:id/text1" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#android:id/text1"
android:layout_below="#+id/spinner1"
android:layout_marginTop="18dp"
android:text="Location:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner1"
android:layout_alignTop="#+id/textView2"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/editText1"
android:layout_marginTop="15dp"
android:text="Start At:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1"
android:layout_alignBottom="#+id/textView1"
android:layout_toRightOf="#+id/textView2"
android:ems="10"
android:inputType="time" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/editText2"
android:layout_marginTop="22dp"
android:text="End At:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/textView3"
android:layout_toRightOf="#+id/textView2"
android:ems="10"
android:inputType="time" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/editText3"
android:layout_marginTop="23dp"
android:text="Alarm:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/btnAlarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignLeft="#+id/editText3"
android:text="Set Alarm" />
<Button
android:id="#+id/btnMain"
style="#style/main_menu"
android:layout_width="170dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="14dp"
android:layout_toRightOf="#+id/textView1"
android:background="#drawable/blue_load_picbutton"
android:text="Main Menu" />
<Button
android:id="#+id/btnEvent"
style="#style/main_menu"
android:layout_width="170dp"
android:layout_height="60dp"
android:layout_above="#+id/btnMain"
android:layout_alignLeft="#+id/btnMain"
android:layout_marginBottom="14dp"
android:background="#drawable/blue_load_picbutton"
android:text="Create Event" />
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/editText1"
android:text="TextView" />
</RelativeLayout>
I do not know the reason as to why the whole screen is shifted. The last time I opened, it was fits in the screen perfectly. Anyone has any idea why, can you please help me? Thanks.
Edited:
After doing according to what #Andy Res said, My screen currently is displayed like this. For your reference, the skin that I am using for my emulator is WVGA854.
I see you allign your Title to the right of txtDate.
And then all the controls are aligned having the Title as a reference.
So I believe this line may cause the shifting to the right.
<TextView
android:id="#android:id/text1"
android:layout_alignRight="#+id/txtDate"
.... />
Try to remove: android:layout_alignRight="#+id/txtDate" and see if any effect.

Categories

Resources