开发者

Relative Layout Android

I have 6 textviews,3 editboxes and two spinners in a Relativelayout.I am trying to add further editboxes in the app. But the app is not showing the additional boxes.

My code is:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <RelativeLayout  
        xmlns:android="http://schemas.android.com/apk/res/android"  
        android:layout_height="fill_parent"  
        android:layout_width="fill_parent"> 


     <TextView  
         android:id="@+id/EditText01"  
         android:text="@string/type1"  
         android:layout_alignParentLeft="true"  
         android:layout_width="fill_parent"
         android:textSize="18sp"  
         android:layout_toLeftOf="@+id/Button01"  
         android:layout_height="wrap_content"></TextView>
     <EditText 
         android:id="@+id/Button01"  
         android:layout_width="wrap_content"  
         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="18sp"
         android:layout_toLeftOf="@+id/Button01"  
         android:layout_height="wrap_content"></TextView>
     <EditText 
         android:id="@+id/Button02"  
         android:layout_width="wrap_content"  
         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="18sp"
         android:layout_toLeftOf="@+id/Button01"  
         android:layout_height="wrap_content"></TextView>
     <EditText 
         android:id="@+id/Button03"  
         android:layout_width="wrap_content"  
         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="18sp"
         android:layout_height="wrap_content"></TextView>     
       <Spinner 
        android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
   开发者_JAVA技巧     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="18sp"
          android:layout_height="wrap_content"></TextView>  
        <Spinner
          android:id="@+id/widget"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          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="18sp"
          android:layout_toLeftOf="@+id/Button04" 
          android:layout_height="wrap_content"></TextView>   
        <EditText
          android:id="@+id/Button04"
          android:layout_width="wrap_content"  
          android:layout_alignParentRight="true"  
          android:layout_height="wrap_content"></EditText>



     </RelativeLayout>

 </ScrollView>  

The last editbox or any element further added is not showing in the app.

Please help.


Can you please update the correct and complete xml file content?

Also, from the GUI designer's point of view, I think these many controls are atrocious on a limited display. Though you have used a ScrollView, I would suggest to rethink over your GUI design.


I think they are actually showing but they may be overlapping previous edit boxes. As a test, I replaced all the @strings with sequential numbers as strings and added an extra edit box to the end of your code and it does appear in the layout but overlaps the last one. Try doing the same thing as a test and you will see what I mean. Hope it goes well for you.

Cheers,


Things that strike me as odd about the last EditText:

  • It's ID'd as a button. Consider using Button if it's a button.
  • It has no content, unless it's set programmatically. So wrap_content on the width will give it a width of 0 (so it's invisible).
  • It's in a RelativeLayout, but you haven't said which other element it should be placed relative to. I think the default is that it'll overlap elements, and just go at the top. But because it has a width of 0, you won't even be able to see it there.

Hope this helps. Death to RelativeLayout. (Not really, it's useful, but I hate it).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜