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>
Related
As Edittext it is not the only one in the group widget. With TextInputLayout the hint didn't work. Tell me is there any way else to summon help?
This is my layout:
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textColorHint="#color/colorTextHint">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/et_account_tint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorTextHint"
android:maxLines="1"
android:theme="#style/EditText"
android:textSize="16sp" />
<EditText
android:id="#+id/et_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:drawableRight="#mipmap/ic_selectcontact"
android:hint="#string/enter_phone_number_contact_name"
android:inputType="text"
android:maxLines="1"
android:textColorHint="#color/colorTextHint"
android:textSize="16sp"
android:theme="#style/EditText" />
<TextView
android:id="#+id/et_account_button"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:color/transparent"
android:onClick="#{presenter::onClick}"
android:textSize="16sp"
tools:ignore="LabelFor" />
</RelativeLayout>
</android.support.design.widget.TextInputLayout>
Do like this
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
app:hintEnabled="true" app:hintAnimationEnabled="false"
android:textColorHint="#color/colorTextHint">
<EditText
android:id="#+id/et_account_tint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorTextHint"
android:maxLines="1"
android:theme="#style/EditText"
android:textSize="16sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
app:hintEnabled="true"
app:hintAnimationEnabled="false"
android:textColorHint="#color/colorTextHint">
<EditText
android:id="#+id/et_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:drawableRight="#mipmap/ic_selectcontact" android:hint="#string/enter_phone_number_contact_name"
android:inputType="text"
android:maxLines="1"
android:textColorHint="#color/colorTextHint"
android:textSize="16sp"
android:theme="#style/EditText" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/et_account_button"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:color/transparent"
android:onClick="#{presenter::onClick}"
android:textSize="16sp"
tools:ignore="LabelFor" />
I am trying to make an android application and I need the middle part of my screen to be scrollable. When I set a ScrollView inside an Relative Layout my application crashes.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backgroundcolor"
android:orientation="vertical">
<TextView
android:id="#+id/tvCijferHalen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView"
android:layout_alignParentEnd="true"
android:layout_alignStart="#+id/etWegingTehalenCijfer"
android:layout_alignTop="#+id/textView"
android:layout_marginEnd="26dp"
android:layout_marginStart="20dp"
android:background="?android:attr/colorPressedHighlight"
android:paddingStart="65dp"
android:paddingTop="15dp"
android:text="0"
android:textColor="?attr/editTextColor"
android:textSize="30dp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/etWatStaan"
android:layout_alignEnd="#+id/etWatStaan"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="328dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:background="#android:color/holo_green_light"
android:paddingStart="65dp"
android:paddingTop="15dp"
android:text="0"
android:textColor="?attr/editTextColor"
android:textSize="30dp" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/tvCijferHalen"
android:layout_above="#+id/etWatStaan"
android:layout_alignStart="#+id/textView"
android:layout_alignEnd="#+id/tvCijferHalen">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativelayout"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:background="#color/backgroundcolor"
android:orientation="vertical">
<EditText
android:id="#+id/etcijfer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="185dp"
android:layout_marginTop="46dp"
android:ems="10"
android:hint="Cijfer 1"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="visible" />
<EditText
android:id="#+id/etweging1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/etcijfer1"
android:layout_alignBottom="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_marginEnd="28dp"
android:layout_marginRight="46dp"
android:layout_marginStart="187dp"
android:layout_toStartOf="#+id/bLess1"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="visible" />
<Button
android:id="#+id/bLess1"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging1"
android:layout_alignParentEnd="true" />
<EditText
android:id="#+id/etcijfer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer1"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 2"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging1"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess2"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess2"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging2"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer2"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 3"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging2"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess2"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess3"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging3"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer3"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 4"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging3"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess3"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess4"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging4"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer4"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 5"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging4"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess4"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess5"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging5"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer5"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 6"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging5"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess5"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess6"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging6"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
<EditText
android:id="#+id/etcijfer7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etcijfer1"
android:layout_alignParentStart="true"
android:layout_below="#+id/etcijfer6"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Cijfer 7"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<EditText
android:id="#+id/etweging7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/etweging1"
android:layout_alignStart="#+id/etweging1"
android:layout_below="#+id/etweging6"
android:layout_marginTop="10dp"
android:layout_toStartOf="#+id/bLess6"
android:ems="10"
android:hint="weging"
android:inputType="numberDecimal"
android:text="1"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:visibility="gone" />
<Button
android:id="#+id/bLess7"
android:layout_width="30dp"
android:layout_height="40dp"
android:background="#android:color/transparent"
android:drawableLeft="#android:drawable/ic_delete"
android:text="Button"
android:layout_alignTop="#+id/etweging7"
android:layout_alignParentEnd="true"
android:visibility="gone"/>
</RelativeLayout>
</ScrollView>
<EditText
android:id="#+id/etWatStaan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/bNiewCijfer"
android:layout_alignEnd="#+id/etWegingTehalenCijfer"
android:layout_alignParentStart="true"
android:layout_marginEnd="200dp"
android:layout_marginRight="48dp"
android:ems="10"
android:hint="Wat wil je staan"
android:inputType="numberDecimal"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray" />
<EditText
android:id="#+id/etWegingTehalenCijfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:ems="10"
android:hint="weging"
android:inputType="number"
android:textColor="#android:color/black"
android:textColorHint="#android:color/darker_gray"
android:layout_alignBaseline="#+id/etWatStaan"
android:layout_alignBottom="#+id/etWatStaan"
android:layout_alignParentStart="true"
android:layout_marginStart="187dp" />
<Button
android:id="#+id/bNiewCijfer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:text="Cijfer Toevoegen"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView7"
android:layout_alignBottom="#+id/textView7"
android:layout_alignEnd="#+id/tvCijferHalen"
android:layout_alignStart="#+id/tvCijferHalen"
android:background="?android:attr/colorMultiSelectHighlight"
android:text="Te halen Cijfer"
android:textAlignment="center"
android:textColor="?attr/editTextColor" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/textView"
android:layout_marginTop="13dp"
android:background="#android:color/holo_green_dark"
android:text="Gemiddelde"
android:textAlignment="center"
android:textColor="?attr/editTextColor" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignEnd="#+id/ScrollView01"
android:layout_alignStart="#+id/tvCijferHalen"
android:layout_marginEnd="71dp"
android:text="Weging"
android:textAlignment="center"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/textView"
android:layout_alignStart="#+id/ScrollView01"
android:layout_alignTop="#+id/ScrollView01"
android:layout_marginTop="31dp"
android:text="Cijfer"
android:textAlignment="center"
android:textColor="#android:color/black" />
Can someone help me ? I am wondering if it's even possible to have only a part of the screen scrollable
Try this approach:
Step 1
Use a LinearLayout as your root element to enable you to use layout_weightattribute;
Step 2
Inside your layout, you can split it into 3 parts each with a layout_weight of .3
For example:
<LinearLayout
...
orientation="vertical"
... >
<LinearLayout
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
<ScrollView
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
<LinearLayout
layout_weight=".3"
layout_width="match_parent"
layout_height="0dp" />
</LinearLayout> !-- end of root layout here
I said .3 just in case you want to have the sections occupy the same size of the window; but you can set them to whatever you want according to your needs.
I hope this helps.
Note A ScrollView only accepts ONE child element!
Good luck!
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>
Developing an app which have 9 edittext fields.
Have a problem with edittext field. It looks fine on xml layout but when i run the app on emulator these field are all around the screen. And when run on real mob they even look worse .(they place themself all around the screen not where i set them )..Don't know what to do. Here is the xml code.
<?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"
android:background="#drawable/zmal"
tools:ignore="ExtraText" >
<TextView
android:id="#+id/showz"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:fontFamily="bold"
android:textColor="#fefdfd"
android:textSize="20sp" />
<Button
android:id="#+id/calc"
android:layout_width="80dp"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/calbu" />
<EditText
android:id="#+id/zktmal6"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal8"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal8"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal9"
android:layout_alignParentRight="true"
android:layout_marginBottom="20dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal5"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal6"
android:layout_alignParentRight="true"
android:layout_marginBottom="35dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal4"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal5"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal9"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/calc"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal1"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal2"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal3"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal4"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal10"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal1"
android:layout_alignParentRight="true"
android:ems="10"
android:inputType="number"
android:textSize="12sp" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/zktmal2"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal3"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:ems="10"
android:inputType="number"
android:textSize="12sp" />
</RelativeLayout>
you can change the width and the height of the items you want.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/showz"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fontFamily="bold"
android:textColor="#fefdfd"
android:textSize="20sp" />
<Button
android:id="#+id/calc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/calbu" />
<EditText
android:id="#+id/zktmal6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal8"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_marginBottom="20dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal5"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_marginBottom="35dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal4"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_marginBottom="14dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal9"
android:layout_width="60dp"
android:layout_height="32dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal1"
android:layout_width="60dp"
android:layout_height="32dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal3"
android:layout_width="60dp"
android:layout_height="32dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal10"
android:layout_width="60dp"
android:layout_height="32dp"
android:ems="10"
android:inputType="number"
android:textSize="12sp" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/zktmal2"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_marginBottom="14dp"
android:ems="10"
android:inputType="number"
android:textSize="12sp" />
</LinearLayout>
In the xml you set:android:layout_above="#+id/YourViewName" I'm think it should be android:layout_above="#id/YourViewName" because you are specifing an id you already created not trying to generate a new one.
Create one by one from bottom to top:
<?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="ExtraText" >
<TextView
android:id="#+id/showz"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:fontFamily="bold"
android:textColor="#fefdfd"
android:textSize="20sp" />
<Button
android:id="#+id/calc"
android:layout_width="80dp"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/zktmal9"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/calc"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal8"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal9"
android:layout_alignParentRight="true"
android:layout_marginBottom="20dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal6"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal8"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal5"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal6"
android:layout_alignParentRight="true"
android:layout_marginBottom="35dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal4"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal5"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal3"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal4"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal2"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal3"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:ems="10"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal1"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal2"
android:layout_alignParentRight="true"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal10"
android:layout_width="60dp"
android:layout_height="32dp"
android:layout_above="#+id/zktmal1"
android:layout_alignParentRight="true"
android:ems="10"
android:inputType="number"
android:textSize="12sp" >
<requestFocus />
</EditText>
</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