2

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>
Community
  • 1
  • 1
Tatson Baptista
  • 445
  • 3
  • 6
  • 18
  • put your linear layout inside `ScrollView` – Iamat8 Nov 26 '15 at 09:21
  • 3
    Possible duplicate of [How to use ScrollView in Android?](http://stackoverflow.com/questions/6674341/how-to-use-scrollview-in-android) – Ravi Nov 26 '15 at 09:23

1 Answers1

4
<?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>
Nas
  • 2,158
  • 1
  • 21
  • 38