I am trying to create a form in android.But When I am trying to enter fields using android pallets its not getting accommodated in the page.I have tried with scrollview also.Please Help.How can I increase the size of the page so that all field can be accommodated. Please Help
My xml code is this:
<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:gravity="fill"
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.app.BloodSugar$PlaceholderFragment" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Blood Glucose Readings" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText1"
android:layout_below="#+id/editText1"
android:layout_marginTop="14dp"
android:text="Is this before or after a meal?" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_marginTop="14dp" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="14dp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner2"
android:layout_below="#+id/spinner2"
android:text="List any medications that you have taken" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_below="#+id/textView4"
android:layout_marginTop="14dp"
android:ems="10" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText2"
android:layout_below="#+id/editText2"
android:layout_marginTop="16dp"
android:text="List any foods that you have eaten" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="14dp"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView5"
android:layout_below="#+id/textView5"
android:ems="10" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView2"
android:layout_centerVertical="true"
android:text="What type of meal was this?" />
</RelativeLayout>
Related
I got three errors come out when i do the activity_main.xml
Below Here is my output Error:
Error:(12, 130) No resource found that matches the given name (at 'text' with value '#string/create_user_account').
Error:(38, 133) No resource found that matches the given name (at 'text' with value '#string/create_user_account').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\minzan\AppData\Local\Android\Sdk\build-tools\23.0.3\aapt.exe'' finished with non-zero exit value 1
Below is my activity_main.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.minzan.qimobileandroid.MainActivity">
<TextView android:id="#+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="#string/create_user_account" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" />
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textPersonName" android:ems="10" android:id="#+id/name" android:layout_below="#+id/textView1" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" />
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/uname" android:layout_below="#+id/name" android:layout_alignRight="#+id/name" android:layout_alignEnd="#+id/name" android:layout_alignLeft="#+id/name" android:layout_alignStart="#+id/name" />
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textPassword" android:ems="10" android:id="#+id/upassword" android:layout_below="#+id/uname" android:layout_alignRight="#+id/uname" android:layout_alignEnd="#+id/uname" />
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textPassword" android:ems="10" android:id="#+id/uRepassword" android:layout_below="#+id/upassword" android:layout_alignRight="#+id/upassword" android:layout_alignEnd="#+id/upassword" />
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="phone" android:ems="10" android:id="#+id/phonenum" android:layout_below="#+id/uRepassword" android:layout_alignRight="#+id/uRepassword" android:layout_alignEnd="#+id/uRepassword" />
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="number" android:ems="10" android:id="#+id/cnic" android:layout_below="#+id/phonenum" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Name:" android:id="#+id/textView" android:layout_alignParentLeft="true" android:layout_above="#+id/uname" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="User Name:" android:id="#+id/textView5" android:layout_above="#+id/upassword" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Password:" android:id="#+id/textView6" android:layout_alignBottom="#+id/upassword" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Re-Password:" android:id="#+id/textView7" android:layout_above="#+id/phonenum" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Phone #:" android:id="#+id/textView8" android:layout_alignBottom="#+id/phonenum" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="CNIC:" android:id="#+id/textView9" android:layout_alignBottom="#+id/cnic" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" />
<Button android:id="#+id/btn_createuser" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="#string/create_user_account" android:layout_alignParentBottom="true" android:layout_toRightOf="#+id/textView8" android:layout_toEndOf="#+id/textView8" android:layout_marginBottom="42dp" />
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/viewid" android:layout_above="#+id/btn_createuser" android:layout_alignRight="#+id/cnic" android:layout_alignEnd="#+id/cnic" />
<!-- <TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_marginTop="22dp"
android:text="#string/lastname"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="20dp"
android:text="#string/username"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView4"
android:layout_below="#+id/textView4"
android:layout_marginTop="20dp"
android:text="#string/password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/firstname"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_below="#+id/textView1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:id="#+id/et_fisrtname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentRight="true"
android:ems="10"
android:layout_toRightOf="#+id/textView6"
android:layout_toEndOf="#+id/textView6">
<requestFocus />
</EditText>
<EditText
android:id="#+id/et_lastname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView3"
android:layout_alignBottom="#+id/textView3"
android:layout_alignLeft="#+id/et_fisrtname"
android:layout_alignRight="#+id/et_fisrtname"
android:ems="10" />
<EditText
android:id="#+id/et_cu_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignLeft="#+id/et_lastname"
android:layout_alignRight="#+id/et_lastname"
android:ems="10" />
<EditText
android:id="#+id/et_cu_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView5"
android:layout_alignBottom="#+id/textView5"
android:layout_alignLeft="#+id/et_cu_username"
android:layout_alignRight="#+id/et_cu_username"
android:ems="10" />
<Button
android:id="#+id/btn_createuser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/create_user_account"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/editText"
android:layout_below="#+id/et_cu_password"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignLeft="#+id/et_cu_password"
android:layout_alignStart="#+id/et_cu_password" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Re-password:"
android:id="#+id/textView"
android:layout_alignBottom="#+id/editText"
android:layout_alignLeft="#+id/textView5"
android:layout_alignStart="#+id/textView5" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText2"
android:layout_below="#+id/editText"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignLeft="#+id/editText"
android:layout_alignStart="#+id/editText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Phone #:"
android:id="#+id/textView6"
android:layout_alignBottom="#+id/editText2"
android:layout_alignLeft="#+id/textView"
android:layout_alignStart="#+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="CNIC:"
android:id="#+id/textView7"
android:layout_below="#+id/editText2"
android:layout_alignLeft="#+id/textView4"
android:layout_alignStart="#+id/textView4"
android:layout_alignParentStart="false" />-->
</RelativeLayout>
add "create_user_account" to your strings.xml file. like,
<string name = "create_user_account">YOUR_TEXT_HERE</string>
I bind the data in gridview in android. but the text not shown in fully. Some letters are hide inside. How to show the full text in android gridview. I got like this.
Loan Amount 100 10000000 10000, this value only I bind the gridview. but the value of Loan Amount should show only Loan Am other words are hide and 10 million value also same like this. I used Relative Layout.
This is my full layout:
<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:minWidth="10dp"
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=".MainActivity" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_marginTop="20dp"
android:text="#string/Input_lblcomp" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="350dip"
android:layout_height="100dip"
android:layout_above="#+id/textView2"
android:layout_marginLeft="90dp"
android:padding="5dip"
android:textSize="14pt" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="14dp"
android:text="#string/Input_state" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="300dip"
android:layout_height="100dip"
android:layout_alignBottom="#+id/textView2"
android:layout_alignLeft="#+id/spinner3"
android:layout_below="#+id/spinner1" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="300dip"
android:layout_height="100dip"
android:layout_alignBottom="#+id/textView3"
android:layout_below="#+id/spinner2"
android:layout_marginLeft="90dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_marginTop="14dp"
android:text="#string/Input_propslno" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView5"
android:layout_below="#+id/textView5"
android:layout_marginTop="16dp"
android:text="#string/txt_pdt" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView7"
android:layout_marginTop="14dp"
android:text="#string/txt_cust" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView7"
android:layout_below="#+id/textView8"
android:layout_marginTop="14dp"
android:text="#string/txt_lntype" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="25dp"
android:text="#string/txt_unit" />
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView8"
android:layout_alignLeft="#+id/editText2"
android:layout_alignTop="#+id/textView8"
android:ems="10"
android:inputType="textPersonName"
android:textSize="15sp" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignLeft="#+id/editText3"
android:layout_alignTop="#+id/textView9"
android:ems="10"
android:inputType="textPersonName"
android:textSize="15sp" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView7"
android:layout_alignLeft="#+id/editText1"
android:layout_alignTop="#+id/textView7"
android:ems="10"
android:inputType="textPersonName"
android:textSize="15sp" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView5"
android:layout_alignBottom="#+id/textView5"
android:layout_alignLeft="#+id/spinner3"
android:ems="10"
android:inputType="textPersonName"
android:textSize="15sp" />
<GridView
android:id="#+id/gridView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView9"
android:layout_below="#+id/editText4"
android:layout_marginTop="31dp"
android:gravity="center_horizontal"
android:minWidth="10dp"
android:numColumns="4"
android:stretchMode="columnWidth"
android:textAlignment="inherit" >
</GridView>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/gridView1"
android:layout_below="#+id/editText4"
android:layout_marginTop="16dp"
android:text="#string/txt_gd_factor" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView10"
android:layout_alignBottom="#+id/textView10"
android:layout_alignRight="#+id/editText4"
android:text="#string/txt_gd_prop" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView6"
android:layout_alignBottom="#+id/textView6"
android:layout_marginLeft="21dp"
android:layout_toRightOf="#+id/textView6"
android:text="#string/txt_gd_maxlmt" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_toRightOf="#+id/textView1"
android:text="#string/txt_gd_minlmt" />
Try to use
android:ellipsize="marquee"
For more detail check this question and this question too.
I hope this will help you.
i have 9 edit texts in one activity and it takes user inputs within certain time..if the user fills them within certain time i have to populate them to the listviw in another activity....and from the listview of another activity..i have to get the same edittexts ...here is the xml view of first activity...
enter code here<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="HardcodedText" >
<EditText
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/editText2"
android:layout_marginRight="90dp"
android:layout_marginTop="38dp"
android:ems="10"
android:hint="2."
tools:ignore="TextFields,HardcodedText" />
<EditText
android:id="#+id/editText4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="31dp"
android:ems="10"
android:hint="3."
android:inputType="textPersonName"
tools:ignore="HardcodedText" />
<EditText
android:id="#+id/editText6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/editText4"
android:ems="10"
android:hint="5."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText6"
android:layout_marginBottom="48dp"
android:layout_toRightOf="#+id/editText6"
android:ems="10"
android:hint="4."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText6"
android:layout_alignParentLeft="true"
android:layout_marginLeft="65dp"
android:ems="10"
android:hint="6."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText5"
android:layout_alignLeft="#+id/editText7"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="7."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText8"
android:layout_below="#+id/editText3"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="8."
tools:ignore="TextFields" />
<EditText
android:id="#+id/editText10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText2"
android:layout_alignBottom="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="43dp"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="9."
tools:ignore="TextFields" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText4"
android:layout_centerHorizontal="true"
android:text="TextView"
tools:ignore="HardcodedText" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="27dp"
android:layout_toRightOf="#+id/textView1"
android:ems="10"
android:focusableInTouchMode="true"
android:hint="1."
tools:ignore="TextFields,HardcodedText" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:linksClickable="true"
android:text="finish" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText6"
android:layout_alignBottom="#+id/editText6"
android:layout_toLeftOf="#+id/button1"
android:text="TextView" />
</RelativeLayout>
and here is the listview activity..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="search saved session"
tools:ignore="TextFields,HardcodedText" >
<requestFocus />
</EditText>
<SearchView
android:id="#+id/searchView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/editText1"
android:layout_toRightOf="#+id/editText1"
tools:ignore="NewApi" >
</SearchView>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignLeft="#+id/editText1"
android:layout_below="#+id/searchView1" >
</ListView>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="15dp"
android:text="saved"
tools:ignore="HardcodedText" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button2"
android:layout_alignBottom="#+id/button2"
android:layout_alignRight="#+id/searchView1"
android:text="about"
tools:ignore="HardcodedText" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button1"
android:layout_alignBottom="#+id/button1"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/button1"
android:text="new session"
tools:ignore="HardcodedText" />
</RelativeLayout>
i have a layout in my android project it takes input from edittext and sends the mail from this information but in layout the background does not show up on whole screen it leaves some space at the bottom so it do not look good
this is my layout:
<?xml version="1.0" encoding="utf-8"?>
<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:scrollbarStyle="insideOverlay"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="530dp"
android:background="#drawable/f4kf6msk"
android:fillViewport="true"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="#string/to"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/to"
android:text="#string/app"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed" />
<EditText
android:id="#+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:textColor="#6495ed"
android:textStyle="bold"
android:layout_below="#+id/textView2"
android:ems="10"
android:hint="#string/from"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:ems="10"
android:textColor="#6495ed"
android:textStyle="bold"
android:hint="#string/too"
android:inputType="textEmailAddress"
/>
<Button
android:id="#+id/button1d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/message"
android:background="#android:color/transparent"
android:gravity="center"
android:text="#string/send"
android:textColor="#6495ed" />
<View
android:id="#+id/View0dfd1"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#808080"
android:paddingBottom="3dp" />
<EditText
android:id="#+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView3"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="23dp"
android:textColor="#6495ed"
android:hint="#string/sub1"
android:textStyle="bold"
android:ems="10" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/from"
android:text="#string/sub"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView5"
android:layout_marginTop="39dp"
android:text="#string/Message"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed"
android:textStyle="bold" />
<EditText
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/subject"
android:ems="10"
android:gravity="top"
android:hint="#string/mess"
android:inputType="textMultiLine"
android:lines="11"
android:textColor="#6495ed"
android:textStyle="bold" />
<View
android:id="#+id/View0sd1"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/button1d"
android:layout_marginTop="14dp"
android:background="#808080"
android:paddingBottom="3dp" />
</RelativeLayout>
</ScrollView>
try to put backround in scroll view property instead in relative layout
I am trying to make my activity screen where there is a form to be filled scrollable but unfortunately, when I tried it crashed the app. I have the following xml for that activity:
<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="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="19dp"
android:text="#string/discountLocationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignRight="#+id/shopCity"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView5"
android:layout_below="#+id/shopDiscount"
android:layout_marginTop="21dp"
android:text="#string/discountDurationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopDiscountDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/shopDiscount"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/shopDiscount"
android:layout_alignParentRight="true"
android:text="#string/discountRateLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView6"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:background="#drawable/roundbutton"
android:text="#string/discountPublishButtonLabel"
android:textColor="#color/white"
android:onClick="SubmitData"
android:width="250dp" />
<EditText
android:id="#+id/shopCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView4"
android:layout_alignRight="#+id/shopName"
android:ems="10"
android:inputType="text" >
</EditText>
<EditText
android:id="#+id/shopDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/shopLocation"
android:layout_below="#+id/shopLocation"
android:layout_marginTop="14dp"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/shopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:ems="10"
android:inputType="text">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/categoriesSpinner"
android:layout_alignRight="#+id/textView2"
android:text="#string/discountCategoryLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Spinner
android:id="#+id/categoriesSpinner"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_above="#+id/shopName"
android:layout_alignLeft="#+id/button1"
android:layout_marginBottom="16dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView2"
android:layout_marginTop="206dp"
android:text="#string/discountCityLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/shopCity"
android:layout_alignLeft="#+id/textView5"
android:layout_marginBottom="18dp"
android:text="#string/discountShopLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView1"
android:layout_marginTop="14dp"
android:gravity="right"
android:text="#string/addDiscountMsg"
android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textDirection="anyRtl" />
</RelativeLayout>
And when I tried to add the following after defining RelativeLayout and before closing RelativeLayout, it broke the app immediately when I run it.
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
...........
</ScrollView>
How can I make it scrollable?
Your app crashes because ScrollView can host only one direct child.
Direct from official documentation:
Layout container for a view hierarchy that can be scrolled by the
user, allowing it to be larger than the physical display. A ScrollView
is a FrameLayout, meaning you should place one child in it containing
the entire contents to scroll; this child may itself be a layout
manager with a complex hierarchy of objects. A child that is often
used is a LinearLayout in a vertical orientation, presenting a
vertical array of top-level items that the user can scroll through.
Look this http://developer.android.com/reference/android/widget/ScrollView.html.
To solve your xml:
<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="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="19dp"
android:text="#string/discountLocationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignRight="#+id/shopCity"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView5"
android:layout_below="#+id/shopDiscount"
android:layout_marginTop="21dp"
android:text="#string/discountDurationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopDiscountDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/shopDiscount"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/shopDiscount"
android:layout_alignParentRight="true"
android:text="#string/discountRateLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView6"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:background="#drawable/roundbutton"
android:text="#string/discountPublishButtonLabel"
android:textColor="#color/white"
android:onClick="SubmitData"
android:width="250dp" />
<EditText
android:id="#+id/shopCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView4"
android:layout_alignRight="#+id/shopName"
android:ems="10"
android:inputType="text" />
<EditText
android:id="#+id/shopDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/shopLocation"
android:layout_below="#+id/shopLocation"
android:layout_marginTop="14dp"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/shopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:ems="10"
android:inputType="text">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/categoriesSpinner"
android:layout_alignRight="#+id/textView2"
android:text="#string/discountCategoryLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Spinner
android:id="#+id/categoriesSpinner"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_above="#+id/shopName"
android:layout_alignLeft="#+id/button1"
android:layout_marginBottom="16dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView2"
android:layout_marginTop="206dp"
android:text="#string/discountCityLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/shopCity"
android:layout_alignLeft="#+id/textView5"
android:layout_marginBottom="18dp"
android:text="#string/discountShopLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView1"
android:layout_marginTop="14dp"
android:gravity="right"
android:text="#string/addDiscountMsg"
android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textDirection="anyRtl" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Do it like this , it will work :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="19dp"
android:text="#string/discountLocationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignRight="#+id/shopCity"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView5"
android:layout_below="#+id/shopDiscount"
android:layout_marginTop="21dp"
android:text="#string/discountDurationLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<EditText
android:id="#+id/shopDiscountDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/shopDiscount"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/shopDiscount"
android:layout_alignParentRight="true"
android:text="#string/discountRateLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView6"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:background="#drawable/roundbutton"
android:text="#string/discountPublishButtonLabel"
android:textColor="#color/white"
android:onClick="SubmitData"
android:width="250dp" />
<EditText
android:id="#+id/shopCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView4"
android:layout_alignRight="#+id/shopName"
android:ems="10"
android:inputType="text" >
</EditText>
<EditText
android:id="#+id/shopDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/shopLocation"
android:layout_below="#+id/shopLocation"
android:layout_marginTop="14dp"
android:ems="10"
android:inputType="number" />
<EditText
android:id="#+id/shopName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dp"
android:ems="10"
android:inputType="text">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/categoriesSpinner"
android:layout_alignRight="#+id/textView2"
android:text="#string/discountCategoryLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<Spinner
android:id="#+id/categoriesSpinner"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_above="#+id/shopName"
android:layout_alignLeft="#+id/button1"
android:layout_marginBottom="16dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView2"
android:layout_marginTop="206dp"
android:text="#string/discountCityLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/shopCity"
android:layout_alignLeft="#+id/textView5"
android:layout_marginBottom="18dp"
android:text="#string/discountShopLabel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/textView1"
android:layout_marginTop="14dp"
android:gravity="right"
android:text="#string/addDiscountMsg"
android:textAlignment="viewEnd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textDirection="anyRtl" />
</RelativeLayout>
</ScrollView>
Hope help you
I think you must enclose your relative layout in your scrollview ( before defining and after closing ) .
EDIT : You must also enclose your relative layout in Liner Layout
ex :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:textDirection="anyRtl"
tools:context=".AddDiscountActivity" >
</RelativeLayout>
</LinearLayout>
</SrcollView>