I'm designing my app and ive come across some sort of bug. On the design view of my application everything looks fine but when i run the emulator its got two of my text boxes on top of each other and im unsure of how to fixing it ?
This is my xml code :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gradient"
tools:context=".Registration_form">
<ImageView
android:id="#+id/imageView2"
android:layout_width="240dp"
android:layout_height="298dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="-1dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="60dp"
app:srcCompat="#drawable/hotellogo" />
<EditText
android:id="#+id/editText1"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginTop="308dp"
android:layout_marginEnd="34dp"
android:layout_marginRight="34dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_fn"
android:ems="10"
android:hint="Full name"
android:inputType="textPersonName"
android:textColor="#E1F7F7"
android:textColorHighlight="#FFFFFF"
android:textColorHint="#807D7D"
android:textSize="16dp" />
<EditText
android:id="#+id/editText2"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginTop="362dp"
android:layout_marginEnd="35dp"
android:layout_marginRight="35dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_user"
android:ems="10"
android:hint="Username (email)"
android:inputType="textEmailAddress"
android:textColor="#E1F7F7"
android:textColorHighlight="#FFFFFF"
android:textColorHint="#807D7D"
android:textSize="16dp" />
<EditText
android:id="#+id/editText3"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="38dp"
android:layout_marginEnd="35dp"
android:layout_marginRight="40dp"
android:layout_marginBottom="285dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_pass"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#E1F7F7"
android:textColorHint="#807D7D" />
<EditText
android:id="#+id/editText4"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="38dp"
android:layout_marginEnd="35dp"
android:layout_marginRight="35dp"
android:layout_marginBottom="239dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_phone"
android:ems="10"
android:hint="Phone"
android:inputType="phone"
android:textColor="#E1F7F7"
android:textColorHint="#807D7D" />
<EditText
android:id="#+id/editText5"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginTop="507dp"
android:layout_marginEnd="34dp"
android:layout_marginRight="34dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_room"
android:ems="10"
android:hint="Room number"
android:inputType="textPersonName"
android:textColor="#E1F7F7"
android:textColorHighlight="#FFFFFF"
android:textColorHint="#807D7D"
android:textSize="16dp" />
This is what it looks like:
This is what it looks like so far
You must use the attribute android:layout_below to position a view below another view inside a RelativeLayout.
I set the margins between the edit texts to 10dp, you can change them if you want:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gradient"
tools:context=".Registration_form">
<ImageView
android:id="#+id/imageView2"
android:layout_width="240dp"
android:layout_height="298dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="-1dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="60dp"
app:srcCompat="#drawable/hotellogo" />
<EditText
android:id="#+id/editText1"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_below="#id/imageView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_fn"
android:ems="10"
android:hint="Full name"
android:inputType="textPersonName"
android:textColor="#E1F7F7"
android:textColorHighlight="#FFFFFF"
android:textColorHint="#807D7D"
android:textSize="16dp" />
<EditText
android:id="#+id/editText2"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_below="#id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_user"
android:ems="10"
android:hint="Username (email)"
android:inputType="textEmailAddress"
android:textColor="#E1F7F7"
android:textColorHighlight="#FFFFFF"
android:textColorHint="#807D7D"
android:textSize="16dp" />
<EditText
android:id="#+id/editText3"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_below="#id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_pass"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#E1F7F7"
android:textColorHint="#807D7D" />
<EditText
android:id="#+id/editText4"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_below="#id/editText3"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_phone"
android:ems="10"
android:hint="Phone"
android:inputType="phone"
android:textColor="#E1F7F7"
android:textColorHint="#807D7D" />
<EditText
android:id="#+id/editText5"
android:layout_width="300dp"
android:layout_height="35dp"
android:layout_below="#id/editText4"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#11000000"
android:drawableLeft="#drawable/ic_action_room"
android:ems="10"
android:hint="Room number"
android:inputType="textPersonName"
android:textColor="#E1F7F7"
android:textColorHighlight="#FFFFFF"
android:textColorHint="#807D7D"
android:textSize="16dp" />
</RelativeLayout>
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>
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 have developed an android app that works fine, but the problem is that when I run my application on small screen phones then some components goes out of screen. So please tell what should I do with my app so that it fits on every screen?
Should I create all of these folders (given below) and copy-paste all of my app's layout files in each of these folders? Or I need to design different layout files for each of these folders?
I am new to android, please help by giving a simple example.
Folders:
res/layout/my_layout.xml
res/layout-small/my_layout.xml
res/layout-large/my_layout.xml
res/layout-xlarge/my_layout.xml
res/layout-xlarge-land/my_layout.xml
res/drawable-mdpi/my_icon.png
res/drawable-hdpi/my_icon.png
res/drawable-xhdpi/my_icon.png
XML of MainActivity of My 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.appdeveloper.appname.MainActivity"
android:background="#ff003b"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/appLogoImage_id"
android:src="#drawable/applogo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="1000dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="50dp"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/loginPassword_id"
android:textAlignment="center"
android:hint="Enter Application Password"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:layout_below="#+id/appLogoImage_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="50dp"
android:background="#android:color/transparent"
android:visibility="visible"
android:textCursorDrawable="#drawable/white_cursor" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="REGISTRATION"
android:id="#+id/regTitle_id"
android:layout_below="#+id/appLogoImage_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#ffffff"
android:textAlignment="center"
android:layout_marginTop="50dp"
android:visibility="invisible"
android:textStyle="bold" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions|text"
android:ems="10"
android:id="#+id/regName_id"
android:layout_below="#+id/loginPassword_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Your Good Name"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="0dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regPassword_id"
android:layout_below="#+id/regName_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Application Password"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regVerifyPass_id"
android:layout_below="#+id/regPassword_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Verify Password"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regRingCode_id"
android:hint="Ringing Codeword"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regVerifyPass_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regLocationCode_id"
android:hint="Location Codeword"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/regRingCode_id"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum1_id"
android:hint="1st Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regLocationCode_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:phoneNumber="false" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum2_id"
android:hint="2nd Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regNum1_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:phoneNumber="false" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum3_id"
android:hint="3rd Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regNum2_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:phoneNumber="false" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register"
android:id="#+id/regButton_id"
android:layout_below="#+id/regNum3_id"
android:layout_marginTop="15dp"
android:layout_alignLeft="#+id/appLogoImage_id"
android:layout_alignStart="#+id/appLogoImage_id"
android:layout_alignRight="#+id/appLogoImage_id"
android:layout_alignEnd="#+id/appLogoImage_id"
android:visibility="invisible" />
</RelativeLayout>
Unless you soft code your dimensions (margin, padding, textsize) in dimen.xml file, your app will have different layout in phones having different ppi (pixel per inch).
So add all your margins specially the one having 1000dp in Dimens.xml.
Reason: Android handles all the cases (hdpi,mdpi,xhdpi, ....) on its own by going through dimens.xml file and in your case you are focusing on the preview screen in XMl layout editor that is having a fixed ppi and ignoring the cases of other screens having different ppi.
Your layout file
<?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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.appdeveloper.appname.MainActivity"
android:background="#ff003b"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/appLogoImage_id"
android:src="#drawable/applogo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/margin_0" />
<EditText
android:layout_width="wrap_content"
android:layout_height="#dimen/margin_50"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/loginPassword_id"
android:textAlignment="center"
android:hint="Enter Application Password"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:layout_below="#+id/appLogoImage_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/margin_50"
android:background="#android:color/transparent"
android:visibility="visible"
android:textCursorDrawable="#drawable/white_cursor" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="REGISTRATION"
android:id="#+id/regTitle_id"
android:layout_below="#+id/appLogoImage_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#ffffff"
android:textAlignment="center"
android:layout_marginTop="#dimen/margin_50"
android:visibility="invisible"
android:textStyle="bold" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions|text"
android:ems="10"
android:id="#+id/regName_id"
android:layout_below="#+id/loginPassword_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Your Good Name"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="#dimen/margin_0"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regPassword_id"
android:layout_below="#+id/regName_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Application Password"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="#dimen/margin_10"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regVerifyPass_id"
android:layout_below="#+id/regPassword_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Verify Password"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="#dimen/margin_10"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regRingCode_id"
android:hint="Ringing Codeword"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regVerifyPass_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/margin_10"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regLocationCode_id"
android:hint="Location Codeword"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/regRingCode_id"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/margin_10"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum1_id"
android:hint="1st Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regLocationCode_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/margin_10"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:phoneNumber="false" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum2_id"
android:hint="2nd Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regNum1_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/margin_10"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:phoneNumber="false" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum3_id"
android:hint="3rd Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regNum2_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/margin_10"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:phoneNumber="false" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register"
android:id="#+id/regButton_id"
android:layout_below="#+id/regNum3_id"
android:layout_marginTop="#dimen/margin_15"
android:layout_alignLeft="#+id/appLogoImage_id"
android:layout_alignStart="#+id/appLogoImage_id"
android:layout_alignRight="#+id/appLogoImage_id"
android:layout_alignEnd="#+id/appLogoImage_id"
android:visibility="invisible" />
</RelativeLayout>
Your dimens.xml in res/values
<resources>
<dimen name="margin_10">10dp</dimen>
<dimen name="margin_0">0dp</dimen>
<dimen name="margin_15">15dp</dimen>
<dimen name="margin_30">30dp</dimen>
<dimen name="margin_50">50dp</dimen>
<dimen name="margin_20">20dp</dimen>
</resources>
I have set width of all the components to wrap_content in MainActivity but wrap_content does not works, I mean when I type into EditText then text appears only in limited width.
I want the TextViews and EditTexts to expand their widths according to input text length.
Please help, what is issue with my code?
MainActivity XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.appdeveloper.appname.MainActivity"
android:background="#ff003b"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/appLogoImage_id"
android:src="#drawable/applogo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="You Can't Proceed Without Inserting Primary Sim (SIM-1) In Your Device!"
android:id="#+id/regNoSim_id"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textAlignment="center"
android:textColor="#ffffff"
android:visibility="invisible"
android:layout_below="#+id/appLogoImage_id"
android:layout_marginTop="50dp"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="REGISTRATION"
android:id="#+id/regTitle_id"
android:layout_below="#+id/appLogoImage_id"
android:textColor="#ffffff"
android:textAlignment="center"
android:layout_marginTop="50dp"
android:visibility="invisible"
android:textStyle="bold"
android:layout_centerHorizontal="true"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/loginPassword_id"
android:overScrollMode="never"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions|text"
android:ems="10"
android:id="#+id/regName_id"
android:hint="Your Name"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="0dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regPassword_id"
android:layout_below="#+id/regName_id"
android:hint="Application Password"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regVerifyPass_id"
android:layout_below="#+id/regPassword_id"
android:hint="Verify Password"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regRingCode_id"
android:hint="Ringing Codeword"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regVerifyPass_id"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/regLocationCode_id"
android:hint="Location Codeword"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regRingCode_id"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum1_id"
android:hint="1st Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regLocationCode_id"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum2_id"
android:hint="2nd Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regNum1_id"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/regNum3_id"
android:hint="3rd Trusted Number"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regNum2_id"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/regEmail_id"
android:hint="Email Address"
android:textAlignment="center"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:background="#android:color/transparent"
android:layout_below="#+id/regNum3_id"
android:layout_marginTop="10dp"
android:textCursorDrawable="#drawable/white_cursor"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<Button
android:layout_width="230dp"
android:layout_height="wrap_content"
android:text="Register"
android:id="#+id/regButton_id"
android:visibility="invisible"
android:layout_centerHorizontal="true"
android:layout_below="#+id/regEmail_id"
android:layout_marginTop="15dp"
android:layout_marginBottom="20dp" />
</RelativeLayout>
</ScrollView>
<EditText
android:layout_width="wrap_content"
android:layout_height="50dp"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/loginPassword_id"
android:textAlignment="center"
android:hint="Enter Application Password"
android:textColor="#ffffff"
android:textColorHint="#000000"
android:layout_below="#+id/appLogoImage_id"
android:layout_marginTop="50dp"
android:background="#android:color/transparent"
android:visibility="invisible"
android:textCursorDrawable="#drawable/white_cursor"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Forgotten Password?"
android:id="#+id/forgottenPass_id"
android:textAlignment="center"
android:textColor="#ffffff"
android:visibility="invisible"
android:layout_below="#+id/loginPassword_id"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:minHeight="30dp" />
</RelativeLayout>
Its because you have set android:ems="10" and that's the limitation remove it and see the difference!
You are thinking it's wrapped and adjust it's size because of your wrap_content but you have set android:ems !
Makes the TextView be exactly this many ems wide.
Refer : https://developer.android.com/reference/android/widget/TextView.html#attr_android:ems
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>