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>
Related
I designed the main activity to be like this:Main Activity design
Unfortunately, it appears like in the real mobile Real Mobile Snapshot
What is wrong?
Below is the XML file of the MainActivity .
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Number 1"
android:inputType="number"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="16dp" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Number 2"
android:inputType="number"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="93dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="206dp"
android:layout_height="41dp"
android:text="TextView"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="249dp" />
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Result"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="189dp" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sum"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="312dp" />
The root layout should be LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Number 1"
android:inputType="number"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="16dp" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Number 2"
android:inputType="number"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="93dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="206dp"
android:layout_height="41dp"
android:text="TextView"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="249dp" />
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Result"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="189dp" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sum"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="312dp" />
</LinearLayout>
So i have a simple fragment in an activity that renders correctly on some devices, but on other devices, components get moved around.
This is what the layout should be like(samsung s4, s5):
But this is what happens on some devices(galaxy note):
layout.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="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.TextInputLayout
android:id="#+id/personName_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Full Name"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="180dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/personName_su"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/companyName_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Company Name"
android:layout_below="#+id/personName_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/companyName_su"
android:layout_below="#+id/personName_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/phoneNumber_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Phone Number"
android:layout_below="#+id/companyName_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/phoneNumber_su"
android:layout_below="#+id/companyName_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/physicalAddress_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Physical Address"
android:layout_below="#+id/phoneNumber_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/physicalAddress_su"
android:layout_below="#+id/phoneNumber_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/hourlyRate_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Hourly Rate(Digits Only)(Optional)"
android:layout_below="#+id/physicalAddress_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/hourlyRate_su"
android:layout_below="#+id/physicalAddress_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/emailAddress_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Email Address"
android:layout_below="#+id/hourlyRate_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/emailAddress_su"
android:layout_below="#+id/hourlyRate_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/password_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Password"
android:layout_below="#+id/emailAddress_su_il"
>
<EditText
android:inputType="textPassword"
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/password_su"
android:layout_below="#+id/emailAddress_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/activation_code_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="#style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Activation Code"
android:layout_below="#+id/password_su_il"
>
<EditText
android:inputType="textPassword"
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="#drawable/round_corners_dark"
android:id="#+id/activation_code_su"
android:layout_below="#+id/password_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="profilePicture"
android:textAllCaps="false"
android:textSize="18dp"
android:background="#drawable/round_corners_list"
android:textColor="#f7f7f7"
android:id="#+id/uploadProPicButton_su"
android:layout_below="#+id/chosenCategories"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="#+id/proPicThumbnail"
android:scaleType="fitXY"
android:background="#ffffff"
android:layout_above="#+id/signUpButton_su"
android:layout_toEndOf="#+id/signUpButton_su" />
<Spinner
android:layout_width="100dp"
android:layout_height="40dp"
android:id="#+id/serviceCategory_su"
android:background="#drawable/round_corners_dark"
android:layout_above="#+id/companyName_su_il"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/personName_su_il"
android:layout_marginLeft="2dp"
android:layout_alignStart="#+id/townSpinner" />
<Button
android:layout_width="250dp"
android:layout_height="40dp"
android:text="register"
android:textSize="18dp"
android:background="#drawable/round_corners_list"
android:textAllCaps="false"
android:textColor="#f7f7f7"
android:id="#+id/signUpButton_su"
android:layout_below="#+id/uploadProPicButton_su"
android:layout_centerHorizontal="true"
android:layout_marginTop="7dp" />
<ImageView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:id="#+id/viewPasswordButton"
android:src="#mipmap/view_icon"
android:layout_marginBottom="3dp"
android:layout_alignBottom="#+id/password_su_il"
android:layout_toEndOf="#+id/password_su_il" />
<Spinner
android:layout_width="150dp"
android:layout_height="40dp"
android:id="#+id/countrySpinner"
android:background="#drawable/round_corners_dark"
android:layout_alignBottom="#+id/companyName_su_il"
android:layout_alignParentEnd="true"
android:layout_alignStart="#+id/serviceCategory_su" />
<Spinner
android:layout_width="150dp"
android:layout_height="40dp"
android:id="#+id/townSpinner"
android:background="#drawable/round_corners_dark"
android:layout_alignBottom="#+id/phoneNumber_su_il"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/chosenCategories"
android:textSize="16dp"
android:textColor="#484848"
android:background="#drawable/round_corners_dark"
android:layout_below="#+id/activation_code_su_il"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/termsAndConditions"
android:textSize="12dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
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 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>
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.