I have 9 Edittext fields to work with. But their is a problem. I set the Edittext fields accordingly but when I run this application on emulator the fields reset them self automatically ( They are not remain at the place where i set them ).And when i run the apk on my mobile (sumsang y S 5360) they look even worse. Here is a Xml code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/zmal"
tools:ignore="ExtraText,TextFields" >
<TextView
android:id="#+id/showz"
android:layout_width="200dip"
android:layout_height="30dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:fontFamily="bold"
android:textColor="#fefdfd"
android:textSize="20sp" />
<Button
android:id="#+id/calc"
android:layout_width="80dip"
android:layout_height="45dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/calbu"
android:paddingBottom="10dp"
android:paddingLeft="5dp" />
<EditText
android:id="#+id/zktmal3"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_below="#+id/zktmal2"
android:layout_marginTop="16dp"
android:ems="10"
android:padding="3dp"
android:inputType="number"
android:textSize="12sp" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/zktmal5"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:ems="10"
android:padding="3dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal8"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_below="#+id/zktmal6"
android:layout_marginTop="27dp"
android:ems="10"
android:padding="3dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal9"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_below="#+id/zktmal8"
android:layout_marginTop="21dp"
android:ems="10"
android:padding="3dp"
android:inputType="number"
android:textSize="12sp"/>
<EditText
android:id="#+id/zktmal10"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_above="#+id/calc"
android:layout_alignParentRight="true"
android:layout_marginBottom="15dp"
android:ems="10"
android:padding="3dp"
android:inputType="number"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal1"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="48dp"
android:ems="10"
android:inputType="number"
android:padding="3dp"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal4"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_above="#+id/zktmal5"
android:layout_alignParentRight="true"
android:layout_marginBottom="24dp"
android:ems="10"
android:inputType="number"
android:padding="3dp"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal2"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_below="#+id/zktmal1"
android:ems="10"
android:inputType="number"
android:padding="3dp"
android:textSize="12sp" />
<EditText
android:id="#+id/zktmal6"
android:layout_width="40dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:layout_below="#+id/zktmal5"
android:ems="10"
android:inputType="number"
android:padding="3dp"
android:textSize="12sp" />
</RelativeLayout
Here is screenshot
http://postimg.org/image/6yf04lx6h/
Use linearlayout and orientation:horizontal for each row:
And use a general relative layout for scroll view.
like this
<ScroolView>
<RelativeLayout>
<LinearLayout />
<LinearLAyout />
<LinearLayout />
.
.
</RelativeLAyout>
<ScrollView>
You don't show how you layout the TextViews in your XML post but it is clear that they are very verbose. When you have such a long TextView to caption an EditText, it would be better to just put the EditText on the next line.
If I were you, I would just have a scrolling layout like so:
<ScrollView>
<TextView android:id="#+id/label1"/>
<EditText> android:id="#+id/edit1"/>
...
...
<TextView android:id="#+id/labelN"/>
<EditText android:id="#+id/editN"/>
</ScrollView>
Related
Hi I have a couple of EditText boxes in a GridLayout. However, the code for the EditText is exactly the same. But they look different onFocus event. Any idea why this is occurring?
The texboxes after each one of them were selected:
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:alignmentMode="alignBounds"
android:columnCount="3"
android:columnOrderPreserved="false"
android:useDefaultMargins="true">
<TextView
android:id="#+id/tvDisinfectionContact"
style="#style/formsubsubheader"
android:layout_width="250dp"
android:layout_columnSpan="3"
android:layout_gravity="fill_horizontal"
android:paddingTop="10dp"
android:text="#string/disinfection_contact" />
<TextView
android:layout_width="300dp"
android:layout_columnSpan="1"
android:gravity="start"
android:visibility="gone" />
<TextView
android:id="#+id/tvPpmUnit"
style="#style/fieldlabel"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_columnSpan="1"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="#string/unit_ppm" />
<TextView
android:id="#+id/tvMinutesUnits"
style="#style/fieldlabel"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_columnSpan="1"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="#string/unit_mins" />
<TextView
android:id="#+id/tvLvlCheAdd"
style="#style/fieldlabel"
android:layout_width="250dp"
android:layout_columnSpan="1"
android:gravity="start"
android:labelFor="#+id/etLvlCheAddPpm"
android:paddingTop="12dp"
android:text="#string/lvl_cheaddition" />
<EditText
android:id="#+id/etLvlCheAddPpm"
android:width="100dp"
android:layout_columnSpan="1"
android:layout_gravity="center_horizontal"
android:ems="16"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:maxLength="50"/>
<EditText
android:id="#+id/etLvlCheAddMinutes"
android:layout_columnSpan="1"
android:layout_gravity="center_horizontal"
android:width="100dp"
android:ems="16"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:maxLength="50" />
<TextView
android:id="#+id/tvLvlFlushADD"
style="#style/fieldlabel"
android:layout_width="250dp"
android:layout_columnSpan="1"
android:gravity="start"
android:labelFor="#+id/etLvlFlushAddPpm"
android:paddingTop="12dp"
android:text="#string/lvl_flushddition" />
<EditText
android:id="#+id/etLvlFlushAddPpm"
android:width="100dp"
android:layout_columnSpan="1"
android:layout_gravity="center_horizontal"
android:ems="16"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:maxLength="50" />
<EditText
android:id="#+id/etLvlFlushMinutes"
android:layout_columnSpan="1"
android:layout_gravity="center_horizontal"
android:width="100dp"
android:ems="16"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:maxLength="50" />
</GridLayout>
On Android O there has been some Input and Navigation Changes . You won't see the changes in the View on different android versions. You can check if your app is running on O, and if so call setDefaultFocusHighlightEnabled(false) on the EditText view.
This sets whether this View should use a default focus highlight when it gets focused but doesn't have R.attr.state_focused defined in its background.
i have my android apps which has its own login information for example for the first time the user must make a sign up profile which will include name ,email ,gender,and profession .now i want to use Facebook(or some one else) login info so that one may login to my app and i have the basic data like name,profession and gender .how can i do that?
I need the following information from Facebook .can i do it? and if yes then how? please answer
<ScrollView
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tvbanner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Create an account"
android:textColor="#FF30B430"
android:textSize="30sp"
android:paddingLeft="1dp"
android:paddingTop="15dp"
android:paddingBottom="5dp"
android:layout_marginTop="-5dp"
android:textStyle="bold|italic"
android:typeface="normal" />
<TableRow
android:layout_below="#+id/meLbl"
android:id="#+id/hr1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF30B430"></TableRow>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:id="#+id/SignUPLayout">
<EditText
android:id="#+id/etfirstname"
android:layout_width="150dp"
android:layout_height="30dp"
android:background="#FFF"
android:hint="First Name"
android:layout_marginTop="15dp"
android:imeOptions="actionNext"
android:singleLine="true"
/>
<EditText
android:layout_width="150dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:singleLine="true"
android:layout_alignParentTop="true"
android:background="#FFF"
android:hint="Last Name"
android:id="#+id/etLastName"
android:layout_marginTop="15dp" />
<EditText
android:id="#+id/etEmail"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_below="#+id/etfirstname"
android:layout_marginTop="15dp"
android:background="#FFF"
android:ems="10"
android:hint="Please Type User Name"
android:inputType="textEmailAddress" />
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/etPassword"
android:layout_below="#+id/etEmail"
android:background="#FFF"
android:hint="Please Type Password"
android:layout_marginTop="15dp"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/etConfirmPassword"
android:layout_below="#+id/etPassword"
android:background="#FFF"
android:hint="Type Password Again"
android:layout_marginTop="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/etConfirmPassword"
android:text="Select Your Profession:"
android:id="#+id/tvProfession"
android:textColor="#FFF"
android:textSize="20dp"
android:layout_marginTop="10dp"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner"
android:popupBackground="#FFF"
android:textAlignment="center"
android:layout_below="#+id/tvProfession"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#FF30B430"
android:spinnerMode="dialog"
android:layout_marginTop="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinner"
android:text="Gender :"
android:id="#+id/tvgender"
android:textColor="#FFF"
android:textSize="20dp"
android:layout_marginTop="10dp">
</TextView>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="#+id/tvgender"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/radioGroup"
>
<RadioButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/Male"
android:textColor="#FFF"
android:buttonTint="#FFF"
android:textStyle="bold" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/Female"
android:text="Female"
android:textColor="#FFF"
android:buttonTint="#FFF"
android:textStyle="bold" />
</RadioGroup>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign Up"
android:id="#+id/signUpButton"
android:background="#drawable/rounded_corners"
android:layout_alignTop="#+id/radioGroup"
android:layout_alignLeft="#+id/etLastName"
android:layout_alignStart="#+id/etLastName"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:clickable="true"
android:onClick="insert"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
Yes you can get user data from Facebook using their official Facebook's Android SDK. https://developers.facebook.com/docs/android/getting-started on their site you can get info about integration of sdk in android app.
I have an android application. I just added the sample advertisments to my app, and I keep having problems with the ad over my EditText.
When I click on the EditText, the advertisment which is at the bottom of the screen moves up above the keyboard.
My code is below:
<?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"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context="org.alexwebber.frc.strongholdcalculator.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/autonomous"
android:textSize="25sp"
android:textStyle="bold"
android:layout_alignParentStart="true"
android:id="#+id/autoLabel" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="#+id/autogrid"
android:layout_below="#+id/autoLabel"
android:layout_alignParentStart="true"
android:layout_marginTop="1dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/defreached"
android:id="#+id/defenseReached"
android:textSize="17sp"
android:layout_row="0"
android:layout_column="0"
android:layout_columnSpan="13" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/defcrossed"
android:textSize="17sp"
android:id="#+id/defcrossed"
android:layout_row="1"
android:layout_column="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lowgoal"
android:textSize="17sp"
android:id="#+id/lowgoalauto"
android:layout_row="2"
android:layout_column="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/highgoal"
android:textSize="17sp"
android:id="#+id/highgoalauto"
android:layout_row="3"
android:layout_column="0" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/autodefreach"
android:textSize="12sp"
android:layout_row="0"
android:layout_column="24"
android:enabled="true"
android:text="#string/total" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/autodefcross"
android:textSize="12sp"
android:enabled="true"
android:text="#string/total"
android:layout_row="1"
android:layout_column="24" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/autolowgoal"
android:enabled="true"
android:text="#string/total"
android:textSize="12sp"
android:layout_row="2"
android:layout_column="24" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/autohighgoal"
android:textSize="12sp"
android:text="#string/total"
android:enabled="true"
android:layout_row="3"
android:layout_column="24" />
</GridLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/teleop"
android:id="#+id/teleopLabel"
android:layout_below="#+id/autogrid"
android:textSize="25sp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_marginTop="0dp" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="175dp"
android:layout_below="#+id/teleopLabel"
android:layout_alignParentStart="true"
android:layout_marginTop="1dp"
android:id="#+id/gridLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/defcrossed"
android:id="#+id/defcrossedtele"
android:textSize="17sp"
android:layout_row="0"
android:layout_column="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lowgoal"
android:id="#+id/lowgoaltele"
android:textSize="17sp"
android:layout_row="1"
android:layout_column="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/highgoal"
android:id="#+id/highgoaltele"
android:textSize="17sp"
android:layout_row="2"
android:layout_column="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/challegedTower"
android:id="#+id/challengestower"
android:textSize="17sp"
android:layout_row="3"
android:layout_column="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/scaledTower"
android:id="#+id/scaledtowertele"
android:textSize="17sp"
android:layout_row="4"
android:layout_column="0" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/teledefcross"
android:text="#string/total"
android:enabled="true"
android:layout_row="0"
android:textSize="12sp"
android:layout_column="13" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/telelowgoal"
android:text="#string/total"
android:enabled="true"
android:layout_row="1"
android:textSize="12sp"
android:layout_column="13" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/telehighgoal"
android:text="#string/total"
android:enabled="true"
android:layout_row="2"
android:textSize="12sp"
android:layout_column="13" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/telechallengedtower"
android:text="#string/total"
android:enabled="true"
android:layout_row="3"
android:textSize="12sp"
android:layout_column="13" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/telescaledtower"
android:text="#string/total"
android:enabled="true"
android:layout_row="4"
android:textSize="12sp"
android:layout_column="13" />
</GridLayout>
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/gridLayout"
android:id="#+id/rpgrid">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/breach"
android:id="#+id/breach"
android:layout_marginTop="1dp"
android:checked="false"
android:layout_row="0"
android:layout_column="0"
android:layout_below="#+id/gridLayout"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/capture"
android:id="#+id/captured"
android:layout_marginTop="1dp"
android:checked="false"
android:layout_row="0"
android:layout_column="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/calculate"
android:id="#+id/button"
android:textSize="20sp"
android:layout_row="1"
android:layout_column="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/totalscore"
android:textSize="20sp"
android:id="#+id/total"
android:layout_row="1"
android:layout_column="1"
android:layout_gravity="right" />
</GridLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:windowSoftInputMode="adjustPan"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
It moves up and overlaps EditText because you set alignParentBottom="true", thus when keyboard shows up, the layout parent bottom is the top of the SoftKeyboard.
You should probably get the solution by adding the all content above the AdView and by calling adjustResize on the Activity declaration in Manifest. On a side note, I'm not sure that calling android:windowSoftInputMode="adjustPan" in AdView xml's widget is going to do something...
Therefore, to handle this behaviour, put the AdView at the top of layout's container and declare a sub-container for the rest of content:
<RelativeLayout ...>
<AdView
android:id="#+id/adView"
android:layout_alignParentBottom="true"
... />
<RelativeLayout
android:layout_above="#id/adView"
...>
<TextView ...>
<GridLayout ...>
<GridLayout ...>
</RelativeLayout>
</RelativeLayout>
Then, make the layout adjusting when keyboard shows up in Manifest.xml:
<activity
android:windowSoftInputMode="adjustResize"
... />
This should work as expected on similar answer. Also, there is another workaround: dynamically detect when the Keyboard is showing up and make the AdView invisible, and vice versa, but I think it does too much hard code than resolved into layout.
Have you set adjustResize for windowSoftInputMode in your Manifest file? this will cause your UI layout to resize when the input method popup. if you don't want to resize, remove it.
<activity
android:name=".TestActivity"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:label="#string/app_name" >
</activity>
http://developer.android.com/training/keyboard-input/visibility.html#Respond
I am almost done with this app, but now that I test it on different devices, all the elements aren't fitting the same way. How do I make it scalable to fit different screens? Or do i have to remake the entire UI from scratch?
XML File
<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.rugpacalc.MainActivity$PlaceholderFragment" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView1"
android:layout_marginLeft="35dp"
android:layout_toRightOf="#+id/textView1"
android:text="Credit " />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_marginLeft="27dp"
android:layout_toRightOf="#+id/textView2"
android:text="Grade " />
<EditText
android:id="#+id/Course1"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText3"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText2"
android:ems="10" />
<EditText
android:id="#+id/editText4"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText3"
android:ems="10" />
<EditText
android:id="#+id/editText5"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText4"
android:ems="10" />
<EditText
android:id="#+id/editText6"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText5"
android:ems="10" />
<EditText
android:id="#+id/editText8"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText2"
android:layout_alignBottom="#+id/editText2"
android:layout_alignLeft="#+id/editText7"
android:ems="10"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText9"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText3"
android:layout_alignBottom="#+id/editText3"
android:layout_alignLeft="#+id/editText8"
android:ems="10"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText10"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText4"
android:layout_alignBottom="#+id/editText4"
android:layout_alignLeft="#+id/editText9"
android:ems="10"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText11"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText5"
android:layout_alignBottom="#+id/editText5"
android:layout_alignLeft="#+id/editText10"
android:ems="10"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText12"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText11"
android:layout_below="#+id/editText5"
android:ems="10"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_alignRight="#+id/textView3"
android:layout_below="#+id/textView2"
android:ems="10" />
<EditText
android:id="#+id/editText14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText8"
android:layout_alignBottom="#+id/editText8"
android:layout_alignLeft="#+id/editText13"
android:layout_alignRight="#+id/editText13"
android:ems="10" />
<EditText
android:id="#+id/editText15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText9"
android:layout_alignBottom="#+id/editText9"
android:layout_alignLeft="#+id/editText14"
android:layout_alignRight="#+id/editText14"
android:ems="10" />
<EditText
android:id="#+id/editText16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText10"
android:layout_alignBottom="#+id/editText10"
android:layout_alignLeft="#+id/editText15"
android:layout_alignRight="#+id/editText15"
android:ems="10" />
<EditText
android:id="#+id/editText17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText11"
android:layout_alignBottom="#+id/editText11"
android:layout_alignLeft="#+id/editText16"
android:layout_alignRight="#+id/editText16"
android:ems="10" />
<EditText
android:id="#+id/editText18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText12"
android:layout_alignBottom="#+id/editText12"
android:layout_alignLeft="#+id/editText17"
android:layout_alignRight="#+id/editText17"
android:ems="10" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText13"
android:layout_alignParentRight="true"
android:text="" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText14"
android:layout_alignParentRight="true"
android:text="" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/editText16"
android:layout_alignParentRight="true"
android:text="" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText16"
android:layout_alignParentRight="true"
android:text="" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText17"
android:layout_alignParentRight="true"
android:text="" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText18"
android:layout_alignParentRight="true"
android:text="" />
<EditText
android:id="#+id/editText7"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_above="#+id/editText8"
android:layout_toRightOf="#+id/Course1"
android:ems="10"
android:hint=""
android:inputType="number|numberDecimal" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView3"
android:layout_alignParentRight="true"
android:text="CreditEd" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView11"
android:layout_below="#+id/textView11"
android:text="Total Credit Pts Earned:" />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView12"
android:layout_below="#+id/textView12"
android:text="Cumulative GPA:" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView13"
android:layout_below="#+id/textView13"
android:layout_marginTop="14dp"
android:text="Semester Credits" />
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView14"
android:text="Semester Credit Points:" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView15"
android:layout_below="#+id/textView15"
android:text="Semester GPA:" />
<TextView
android:id="#+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView11"
android:layout_toLeftOf="#+id/textView4"
android:text="" />
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView12"
android:layout_alignBottom="#+id/textView12"
android:layout_alignRight="#+id/textView17"
android:text="" />
<TextView
android:id="#+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView18"
android:layout_below="#+id/textView18"
android:text="" />
<TextView
android:id="#+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView15"
android:layout_alignLeft="#+id/textView19"
android:text="" />
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView15"
android:layout_alignBottom="#+id/textView15"
android:layout_alignRight="#+id/textView20"
android:text="" />
<TextView
android:id="#+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView21"
android:layout_below="#+id/textView21"
android:text="" />
<TextView
android:id="#+id/tv23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView17"
android:layout_toRightOf="#+id/editText18"
android:text="TextView" />
<TextView
android:id="#+id/tv24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView18"
android:layout_alignBottom="#+id/textView18"
android:layout_alignLeft="#+id/tv23"
android:text="TextView" />
<TextView
android:id="#+id/tv25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView14"
android:layout_alignLeft="#+id/tv24"
android:text="TextView" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView15"
android:layout_below="#+id/button2"
android:text="Total Credits Completed:" />
<Button
android:id="#+id/button1"
android:layout_width="60dp"
android:layout_height="35dp"
android:layout_alignLeft="#+id/button2"
android:layout_alignRight="#+id/textView08"
android:layout_below="#+id/editText6"
android:layout_marginTop="70dp"
android:text="Calculate" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignLeft="#+id/textView11"
android:layout_alignRight="#+id/textView08"
android:layout_below="#+id/button1"
android:text="Next" />
<EditText
android:id="#+id/EditText01"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText6"
android:layout_below="#+id/editText6"
android:ems="10" />
<EditText
android:id="#+id/EditText02"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button1"
android:layout_below="#+id/EditText01"
android:ems="10" />
<EditText
android:id="#+id/EditText05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/EditText04"
android:layout_alignLeft="#+id/editText18"
android:layout_alignRight="#+id/editText18"
android:ems="10" />
<EditText
android:id="#+id/EditText06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/EditText05"
android:layout_alignRight="#+id/EditText05"
android:layout_below="#+id/EditText03"
android:ems="10" />
<TextView
android:id="#+id/textView07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/EditText05"
android:layout_alignParentRight="true" />
<TextView
android:id="#+id/textView08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/EditText06"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/editText2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_below="#+id/Course1"
android:layout_toLeftOf="#+id/editText8"
android:ems="10" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/Course1"
android:layout_alignParentTop="true"
android:layout_marginTop="42dp"
android:text="Course" />
<EditText
android:id="#+id/EditText03"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_above="#+id/EditText02"
android:layout_toRightOf="#+id/EditText01"
android:ems="10"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/EditText04"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_below="#+id/EditText01"
android:layout_toRightOf="#+id/EditText01"
android:ems="10"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignLeft="#+id/textView1"
android:layout_alignParentTop="true"
android:ems="10"
android:hint="Enter Semester" />
</RelativeLayout>
The answer would be too large... If you mean to keep the proportions you can use weight rather than dps. Anyway I recomend you to read this article:
http://developer.android.com/guide/practices/screens_support.html
So, I want to have a scrollview on my layout. I did this and got a scroll view can only have one child :
<?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"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="95dip"
android:layout_marginRight="5dip"
android:layout_marginTop="10dip"
android:text="Latitude: "
android:textSize="15dip" >
</TextView>
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="unknown"
android:textSize="15dip" >
</TextView>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="90dip"
android:layout_marginRight="5dip"
android:text="Longitute: "
android:textSize="15dip" >
</TextView>
<TextView
android:id="#+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="unknown"
android:textSize="15dip" >
</TextView>
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="130dip"
android:layout_height="30dip"
android:layout_marginLeft="95dip"
android:layout_marginTop="10dip"
android:text="Find Coordinates"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextName"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:layout_marginTop="20dip"
android:ems="10"
android:hint="Enter Location Name"
android:textSize="10dip" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editTextPhone"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:layout_marginTop="0dip"
android:ems="10"
android:hint="Enter Phone Number"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextEmail"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:ems="10"
android:hint="Enter Email"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextDesc"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:ems="10"
android:hint="Enter Description"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextFlowers"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dip"
android:hint="Flowers"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextPlants"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="180dip"
android:layout_marginTop="-35dip"
android:hint="Plants"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextFruit"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dip"
android:hint="Fruit"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextVeggies"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="180dip"
android:layout_marginTop="-35dip"
android:hint="Veggies"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextSun"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="115dip"
android:ems="10"
android:hint="Sunday"
android:textSize="10dip" />
<Button
android:id="#+id/saveLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="90dip"
android:layout_marginTop="10dip"
android:text="Save Location" />
<Button
android:id="#+id/seeAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="120dip"
android:text="See all" />
</ScrollView>
Then, following the answer to this question
java.lang.IllegalStateException: ScrollView can host only one direct child
I did this:
<?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="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="95dip"
android:layout_marginRight="5dip"
android:layout_marginTop="10dip"
android:text="Latitude: "
android:textSize="15dip" >
</TextView>
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="unknown"
android:textSize="15dip" >
</TextView>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation = "vertical" >
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="90dip"
android:layout_marginRight="5dip"
android:text="Longitute: "
android:textSize="15dip" >
</TextView>
<TextView
android:id="#+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="unknown"
android:textSize="15dip" >
</TextView>
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="130dip"
android:layout_height="30dip"
android:layout_marginLeft="95dip"
android:layout_marginTop="10dip"
android:text="Find Coordinates"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextName"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:layout_marginTop="20dip"
android:ems="10"
android:hint="Enter Location Name"
android:textSize="10dip" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editTextPhone"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:layout_marginTop="0dip"
android:ems="10"
android:hint="Enter Phone Number"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextEmail"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:ems="10"
android:hint="Enter Email"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextDesc"
android:layout_width="264dp"
android:layout_height="wrap_content"
android:layout_marginLeft="25dip"
android:ems="10"
android:hint="Enter Description"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextFlowers"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dip"
android:hint="Flowers"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextPlants"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="180dip"
android:layout_marginTop="-35dip"
android:hint="Plants"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextFruit"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="50dip"
android:hint="Fruit"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextVeggies"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="180dip"
android:layout_marginTop="-35dip"
android:hint="Veggies"
android:ems="10"
android:textSize="10dip" />
<EditText
android:id="#+id/editTextSun"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginLeft="115dip"
android:ems="10"
android:hint="Sunday"
android:textSize="10dip" />
<Button
android:id="#+id/saveLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="90dip"
android:layout_marginTop="10dip"
android:text="Save Location" />
<Button
android:id="#+id/seeAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="120dip"
android:text="See all" />
</ScrollView>
but still no luck. Any ideas? Thanks.
The key here is
ScrollView can host only one direct child
"direct" being the keyword. So you can have
<ScrollView
...>
<LinearLayout>
....
<!-- you can have as many Views in here as you want -->
</LinearLayout>
</ScrollView>
So, the LinearLayout in the above example would be your one direct child. And that child can have as many children as you want. Which means you can have all of your other LinearLayouts inside that first one. But you can't have more than one on the same hierarchical level.