Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
670 views
in Technique[技术] by (71.8m points)

android - RelativeLayout scrollview

I have an app with a few textboxes and editboxes. The app is working fine but when I am trying to add the scrollview element to see the lower part of app the application is forcibly closing.

My code is:

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout  
     xmlns:android="http://schemas.android.com/apk/res/android"  
     android:layout_height="fill_parent"  
     android:layout_width="fill_parent"> 

    <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">  

    <TextView  
         android:id="@+id/EditText01"  
         android:text="@string/type1"  
         android:layout_alignParentLeft="true"  
         android:layout_width="fill_parent"
         android:textSize="20sp"  
         android:layout_toLeftOf="@+id/Button01"  
         android:layout_height="wrap_content"></TextView>
     <EditText 
         android:id="@+id/Button01"  
         android:layout_width="100sp"  
         android:layout_alignParentRight="true"  
         android:layout_height="wrap_content"></EditText>

      <TextView  
         android:id="@+id/EditText02"  
         android:text="@string/type2"  
         android:layout_alignParentLeft="true"  
         android:layout_below="@id/EditText01"
         android:layout_width="fill_parent"  
         android:textSize="20sp"
         android:layout_toLeftOf="@+id/Button01"  
         android:layout_height="wrap_content"></TextView>
     <EditText 
         android:id="@+id/Button02"  
         android:layout_width="100sp"   
         android:layout_alignParentRight="true"  
         android:layout_below="@id/Button01"
         android:layout_height="wrap_content"></EditText>   

     <TextView  
         android:id="@+id/EditText03"  
         android:text="@string/type3"  
         android:layout_alignParentLeft="true"  
         android:layout_below="@id/EditText02"
         android:layout_width="fill_parent"  
         android:textSize="20sp"
         android:layout_toLeftOf="@+id/Button01"  
         android:layout_height="wrap_content"></TextView>
     <EditText 
         android:id="@+id/Button03"  
         android:layout_width="100sp"   
         android:layout_alignParentRight="true"  
         android:layout_below="@id/Button02"
         android:layout_height="wrap_content"></EditText>     

      <TextView  
         android:id="@+id/EditText04"  
         android:text="@string/property"  
         android:layout_below="@id/EditText03"
         android:layout_width="fill_parent"  
         android:textSize="20sp"
         android:layout_height="wrap_content"></TextView>     
       <Spinner 
        android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/Button03"
        android:prompt="@string/property"></Spinner>

        <TextView
          android:id="@+id/EditText05"
          android:text="@string/propage"
          android:layout_below="@id/spinner"
              android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_height="wrap_content"></TextView>  
        <Spinner
          android:id="@+id/widget"
          android:layout_width="fill_parent"
          android:layout_height="50sp"
          android:layout_below="@+id/EditText05"
          android:prompt="@string/propage"></Spinner>

          <TextView
          android:id="@+id/EditText06"
          android:text="@string/income"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/widget"
          android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_toLeftOf="@+id/Button04" 
          android:layout_height="wrap_content"></TextView>   
          <EditText 
          android:id="@+id/Button04"  
          android:layout_width="100sp"   
          android:layout_alignParentRight="true"  
          android:layout_below="@id/widget"
          android:layout_height="wrap_content"></EditText>  

          <TextView
          android:id="@+id/EditText07"
          android:text="@string/borrow"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/EditText06"
          android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_toLeftOf="@+id/Button05" 
          android:layout_height="wrap_content"></TextView>   
          <EditText 
          android:id="@+id/Button05"  
          android:layout_width="100sp"   
          android:layout_alignParentRight="true"  
          android:layout_below="@id/Button04"
          android:layout_height="wrap_content"></EditText>  

          <TextView
          android:id="@+id/EditText08"
          android:text="@string/interest"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/EditText07"
          android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_toLeftOf="@+id/Button06" 
          android:layout_height="wrap_content"></TextView>   
          <EditText 
          android:id="@+id/Button06"  
          android:layout_width="100sp"   
          android:layout_alignParentRight="true"
          android:layout_below="@id/Button05"
          android:layout_height="wrap_content"></EditText>

          <Button
          android:id="@+id/Button07"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:text="@string/self_destruct"
          android:layout_below="@+id/EditText08"
          android:onClick="selfDestruct" />

          <TextView
          android:id="@+id/EditText09"
          android:text="@string/output1"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/Button07"
          android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_toLeftOf="@+id/Button10" 
          android:layout_height="wrap_content"></TextView>   
          <TextView 
          android:id="@+id/EditText10"  
          android:text="@string/output2"
          android:layout_width="100sp"   
          android:layout_alignParentRight="true"
          android:layout_below="@id/Button07"
          android:layout_toRightOf="@+id/EditText09"
          android:layout_height="wrap_content"></TextView>

          <TextView
          android:id="@+id/EditText11"
          android:text="@string/output3"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/EditText09"
          android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_toLeftOf="@+id/EditText12" 
          android:layout_height="wrap_content"></TextView>   
          <TextView 
          android:id="@+id/EditText12" 
          android:text="@string/output4" 
          android:layout_width="100sp"   
          android:layout_alignParentRight="true"
          android:layout_below="@id/EditText10"
          android:layout_height="wrap_content"></TextView>

          <TextView
          android:id="@+id/EditText13"
          android:text="@string/output5"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/EditText11"
          android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_toLeftOf="@+id/EditText14" 
          android:layout_height="wrap_content"></TextView>   
          <TextView 
          android:id="@+id/EditText14"  
          android:text="@string/output6"
          android:layout_width="100sp"   
          android:layout_alignParentRight="true"
          android:layout_below="@id/EditText12"
          android:layout_height="wrap_content"></TextView>

          <TextView
          android:id="@+id/EditText15"
          android:text="@string/output7"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/EditText13"
          android:layout_width="fill_parent"
          android:textSize="20sp"
          android:layout_toLeftOf="@+id/Button16" 
          android:layout_height="wrap_content"></TextView>   
          <TextView 
          android:id="@+id/EditText16"  
          android:text="@string/output8"
          android:layout_width="100sp"   
          android:layout_alignParentRight="true"
          android:layout_below="@id/EditText14"
          android:layout_height="wrap_content"></TextView>


     </ScrollView>

     </RelativeLayout>

Please help. thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the following format of layout

 <ScrollView>   

    <RelativeLayout> 
               // Use textviews used above here
    </RelativeLayout> 

 </ScrollView>  

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...