views:

58

answers:

1

i am a newbie android developer. I am using scrollView in my application. The application will take some profile information from user and will save it in database. There are 2 EditText fields which are broken in scrollView. I have tried my best to solve it but failed. Please help me if anyone knows what is the problem. here is my layout Code.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="wrap_content" android:layout_width="fill_parent">
 <ScrollView 
  android:id="@+id/ScrollView" 
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_marginBottom="50dip" >
   <RelativeLayout
    android:id="@+id/layoutR"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
    <ImageView
    android:id="@+id/galleryPic"
    android:layout_width="140px"
    android:layout_height="175px"
    android:background="#ff666666" />
   <TextView
 android:id="@+id/lblmail"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:layout_alignParentTop="true"
 android:layout_marginLeft="5dip"
 android:text="E_mail:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/galleryPic"/>
   <EditText
 android:id="@+id/txt_email"
 android:layout_width="170px"
 android:layout_height="32px"
 android:layout_marginLeft="5dip"
 android:hint="e-mail"
 android:maxLines="1"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/galleryPic"
 android:layout_below="@+id/lblmail"/>
   <TextView
 android:id="@+id/lblpass"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:layout_marginLeft="5dip"
 android:text="Password:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/galleryPic"
 android:layout_below="@+id/txt_email"/>
<EditText
 android:id="@+id/txt_pass"
 android:layout_width="170px"
 android:layout_height="32px"
 android:password="true"
 android:maxLines="1"
 android:layout_marginLeft="5dip"
 android:hint="password"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/galleryPic"
 android:layout_below="@+id/lblpass"/>
<TextView
 android:id="@+id/lblrepass"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:layout_marginLeft="5dip"
 android:text="Re-Password:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/galleryPic"
 android:layout_below="@+id/txt_pass"/> 
    <EditText
 android:id="@+id/txt_repass"
 android:layout_width="170px"
 android:layout_height="32px"
 android:password="true"
 android:maxLines="1"
 android:layout_marginLeft="5dip"
 android:hint="re-password"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/galleryPic"
 android:layout_below="@+id/lblrepass"/>
<Button
    android:id="@+id/btn_Gallery"
    android:layout_width="wrap_content"
    android:layout_height="35px" 
    android:gravity="center"
    android:typeface="serif"
    android:textStyle="bold"
    android:text="Browse"
    android:layout_below="@+id/galleryPic"/>
    <TextView
 android:id="@+id/lblname"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:text="Name:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="6dip"
 android:layout_below="@+id/btn_Gallery"/>
<EditText
 android:id="@+id/txt_name"
 android:layout_width="224px"
 android:layout_height="32px"
 android:hint="name"
 android:maxLines="1"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="3dip"
 android:layout_toRightOf="@+id/lblname"
 android:layout_below="@+id/btn_Gallery"
 android:layout_marginLeft="5dip"/>
<TextView
 android:id="@+id/lblage"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:text="Age:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="9dip"
 android:layout_below="@+id/lblname"/>
<EditText
 android:id="@+id/txt_age"
 android:layout_width="225px"
 android:layout_height="32px"
 android:hint="age"
 android:numeric="integer"
 android:maxLines="1"
 android:maxLength="3"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/lblage"
 android:layout_below="@+id/txt_name"
 android:layout_marginLeft="19dip"/>
<TextView
 android:id="@+id/lblsex"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:text="Sex:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="12dip"
 android:layout_below="@+id/lblage"/>
<EditText
 android:id="@+id/txt_sex"
 android:layout_width="226px"
 android:layout_height="32px"
 android:hint="sex"
 android:maxLines="1"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/lblsex"
 android:layout_below="@+id/txt_age"
 android:layout_marginLeft="20dip"/>
<TextView
 android:id="@+id/lbllocation"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:text="Location:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="12dip"
 android:layout_below="@+id/lblsex"/>
<EditText
 android:id="@+id/txt_location"
 android:layout_width="206px"
 android:layout_height="32px"
 android:hint="location"
 android:maxLines="1"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/lbllocation"
 android:layout_below="@+id/txt_sex"
 android:layout_marginLeft="5dip"/>
<TextView
 android:id="@+id/lblstatus"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:text="Status:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="12dip"
 android:layout_below="@+id/lbllocation"/>
<EditText
 android:id="@+id/txt_status"
 android:layout_width="220px"
 android:layout_height="32px"
 android:hint="status"
 android:maxLines="1"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/lblstatus"
 android:layout_below="@+id/txt_location"
 android:layout_marginLeft="5dip"/>
<TextView
 android:id="@+id/lblinterest"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:text="Interest:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="12dip"
 android:layout_below="@+id/lblstatus"/>
<EditText
 android:id="@+id/txt_interest"
 android:layout_width="206px"
 android:layout_height="21px"
 android:hint="interest"
 android:maxLines="1"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/lblinterest"
 android:layout_below="@+id/txt_status"
 android:layout_marginLeft="5dip"/>
<TextView
 android:id="@+id/lblorientation"
 android:layout_width="wrap_content"
 android:layout_height="21px"
 android:text="Orientation:"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_marginTop="12dip"
 android:layout_below="@+id/lblinterest"/>
<EditText
 android:id="@+id/txt_orientation"
 android:layout_width="125px"
 android:layout_height="21px"
 android:hint="status"
 android:maxLines="1"
 android:textSize="10sp"
 android:typeface="serif"
 android:textStyle="bold"
 android:layout_toRightOf="@+id/lblorientation"
 android:layout_below="@+id/txt_interest"
 android:layout_marginLeft="5dip"/>


   </RelativeLayout>

 </ScrollView>
 <RelativeLayout
 android:layout_marginTop="-50dip" 
  android:gravity="bottom"
  android:layout_height="50px" 
  android:layout_width="fill_parent"
    android:background="#ff999999" >

    <Button 
     android:id="@+id/btnNext" 
     android:layout_width="100px" 
     android:layout_height="45px" 
     android:text="Next"
     android:layout_marginTop="2dip"
     android:layout_alignParentRight="true"/>
 </RelativeLayout>

//Zeeshan

+1  A: 

Here, this works:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_height="wrap_content"
    android:layout_width="fill_parent">
    <ScrollView android:id="@+id/ScrollView"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_marginBottom="50dip">
        <RelativeLayout android:id="@+id/layoutR"
            android:layout_width="fill_parent" android:layout_height="wrap_content">
            <ImageView android:id="@+id/galleryPic"
                android:layout_width="140px" android:layout_height="175px"
                android:background="#ff666666" />
            <TextView android:id="@+id/lblmail" android:layout_width="wrap_content"
                android:layout_height="21px" android:layout_alignParentTop="true"
                android:layout_marginLeft="5dip" android:text="E_mail:"
                android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/galleryPic" />
            <EditText android:id="@+id/txt_email" android:layout_width="170px"
                android:layout_height="32px" android:layout_marginLeft="5dip"
                android:hint="e-mail" android:maxLines="1" android:textSize="10sp"
                android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/galleryPic" android:layout_below="@+id/lblmail" />
            <TextView android:id="@+id/lblpass" android:layout_width="wrap_content"
                android:layout_height="21px" android:layout_marginLeft="5dip"
                android:text="Password:" android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/galleryPic" android:layout_below="@+id/txt_email" />
            <EditText android:id="@+id/txt_pass" android:layout_width="170px"
                android:layout_height="32px" android:password="true"
                android:maxLines="1" android:layout_marginLeft="5dip" android:hint="password"
                android:textSize="10sp" android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/galleryPic" android:layout_below="@+id/lblpass" />
            <TextView android:id="@+id/lblrepass" android:layout_width="wrap_content"
                android:layout_height="21px" android:layout_marginLeft="5dip"
                android:text="Re-Password:" android:typeface="serif"
                android:textStyle="bold" android:layout_toRightOf="@+id/galleryPic"
                android:layout_below="@+id/txt_pass" />
            <EditText android:id="@+id/txt_repass" android:layout_width="170px"
                android:layout_height="32px" android:password="true"
                android:maxLines="1" android:layout_marginLeft="5dip" android:hint="re-password"
                android:textSize="10sp" android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/galleryPic" android:layout_below="@+id/lblrepass" />
            <Button android:id="@+id/btn_Gallery" android:layout_width="wrap_content"
                android:layout_height="35px" android:gravity="center"
                android:typeface="serif" android:textStyle="bold" android:text="Browse"
                android:layout_below="@+id/galleryPic" />
            <TextView android:id="@+id/lblname" android:layout_width="wrap_content"
                android:layout_height="21px" android:text="Name:" android:typeface="serif"
                android:textStyle="bold" android:layout_marginTop="6dip"
                android:layout_below="@+id/btn_Gallery" />
            <EditText android:id="@+id/txt_name" android:layout_width="224px"
                android:layout_height="32px" android:hint="name" android:maxLines="1"
                android:textSize="10sp" android:typeface="serif" android:textStyle="bold"
                android:layout_marginTop="3dip" android:layout_toRightOf="@+id/lblname"
                android:layout_below="@+id/btn_Gallery" android:layout_marginLeft="5dip" />
            <TextView android:id="@+id/lblage" android:layout_width="wrap_content"
                android:layout_height="21px" android:text="Age:" android:typeface="serif"
                android:textStyle="bold" android:layout_marginTop="9dip"
                android:layout_below="@+id/lblname" />
            <EditText android:id="@+id/txt_age" android:layout_width="225px"
                android:layout_height="32px" android:hint="age" android:numeric="integer"
                android:maxLines="1" android:maxLength="3" android:textSize="10sp"
                android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/lblage" android:layout_below="@+id/txt_name"
                android:layout_marginLeft="19dip" />
            <TextView android:id="@+id/lblsex" android:layout_width="wrap_content"
                android:layout_height="21px" android:text="Sex:" android:typeface="serif"
                android:textStyle="bold" android:layout_marginTop="12dip"
                android:layout_below="@+id/lblage" />
            <EditText android:id="@+id/txt_sex" android:layout_width="226px"
                android:layout_height="32px" android:hint="sex" android:maxLines="1"
                android:textSize="10sp" android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/lblsex" android:layout_below="@+id/txt_age"
                android:layout_marginLeft="20dip" />
            <TextView android:id="@+id/lbllocation"
                android:layout_width="wrap_content" android:layout_height="21px"
                android:text="Location:" android:typeface="serif" android:textStyle="bold"
                android:layout_marginTop="12dip" android:layout_below="@+id/lblsex" />
            <EditText android:id="@+id/txt_location"
                android:layout_width="206px" android:layout_height="32px"
                android:hint="location" android:maxLines="1" android:textSize="10sp"
                android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/lbllocation" android:layout_below="@+id/txt_sex"
                android:layout_marginLeft="5dip" />
            <TextView android:id="@+id/lblstatus" android:layout_width="wrap_content"
                android:layout_height="21px" android:text="Status:"
                android:typeface="serif" android:textStyle="bold"
                android:layout_marginTop="12dip" android:layout_below="@+id/lbllocation" />
            <EditText android:id="@+id/txt_status" android:layout_width="220px"
                android:layout_height="32px" android:hint="status" android:maxLines="1"
                android:textSize="10sp" android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/lblstatus" android:layout_below="@+id/txt_location"
                android:layout_marginLeft="5dip" />
            <EditText android:id="@+id/txt_interest"
                android:layout_width="210px" android:layout_height="32px"
                android:hint="interest" android:maxLines="1" android:textSize="10sp"
                android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/lblinterest" android:layout_below="@+id/txt_status"
                android:layout_marginLeft="5dip" />
            <EditText android:id="@+id/txt_orientation"
                android:layout_width="125px" android:layout_height="32px"
                android:hint="status" android:maxLines="1" android:textSize="10sp"
                android:typeface="serif" android:textStyle="bold"
                android:layout_toRightOf="@+id/lblorientation" android:layout_below="@+id/txt_interest"
                android:layout_marginLeft="5dip" />

            <TextView android:id="@+id/lblinterest"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:text="Interest:" android:typeface="serif" android:textStyle="bold"
                android:layout_marginTop="12dip" android:layout_below="@+id/lblstatus" />

            <TextView android:id="@+id/lblorientation"
                android:layout_width="wrap_content" android:layout_height="21px"
                android:text="Orientation:" android:typeface="serif"
                android:textStyle="bold" android:layout_marginTop="12dip"
                android:layout_below="@+id/lblinterest" />


        </RelativeLayout>

    </ScrollView>
    <RelativeLayout android:layout_marginTop="-50dip"
        android:gravity="bottom" android:layout_height="50px"
        android:layout_width="fill_parent" android:background="#ff999999">

        <Button android:id="@+id/btnNext" android:layout_width="100px"
            android:layout_height="45px" android:text="Next"
            android:layout_marginTop="2dip" android:layout_alignParentRight="true" />
    </RelativeLayout>
</LinearLayout>

Now, on another note, you should not use px, if you must use a numeric value for height or width use dip or dp, it will adapt to diferent screens, px will not. I would recomend trying to get it to look well using wrap_content & fill_parent as it will work in a broader spectrum of screens.

blindstuff