2012-02-20 127 views
0

有这种布局的CSS:Android的布局XML文件语法错误

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

     <TextView 
      android:id="@+id/add_problem_form_title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/feedbacktitle" 
      android:textSize="10pt"> 
     </TextView> 

     <EditText 
      android:id="@+id/problem_name" 
      android:layout_height="wrap_content" 
      android:hint="@string/feedbackname" 
      android:inputType="textPersonName" 
      android:layout_width="fill_parent"> 
     </EditText>   

     <EditText 
      android:id="@+id/problem_text" 
      android:layout_height="wrap_content" 
      android:hint="@string/feedbackbody" 
      android:inputType="textMultiLine" 
      android:lines="5" 
      android:layout_width="fill_parent"> 
     </EditText> 

     <Button 
      android:id="@+id/button_send_feedback" 
      android:layout_height="wrap_content" 
      android:text="@string/feedbackbutton" 
      android:onClick="sendFeedback" 
      android:layout_width="fill_parent"> 
     </Button>    

    </LinearLayout> 
</ScrollView> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="First, add the problem you want to solve!" 
    /> 

<TextView 
    android:id="@+id/add_problem_text"  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Add a Problem You Want To See Solved" 
    />  

    <Button 
    android:id="@+id/add_problem_button" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Add a Problem" 
    /> 

    <Button 
    android:id="@+id/browse_problems_button" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Browse Problems" 

    /> 
    <Button 
    android:id="@+id/search_problems_button" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Search Problems" 
    /> 

    <Button 
    android:id="@+id/my_problems_button"   
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="View My Problems" 
    />  
</LinearLayout> 

系统说我把它放在一起不正确。我在顶部添加了一些东西来创建表单,但我想这不是它要完成的方式。

安排这些元素的正确方法是什么?顺便说一下,这里有来自2个不同视图的UI元素。这可以吗?

谢谢!

回答

2

必须只有一个根元素。

让我们试试这个,我刚才说了根的LinearLayout和填充它的父:

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

      <TextView 
       android:id="@+id/add_problem_form_title" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/feedbacktitle" 
       android:textSize="10pt"> 
      </TextView> 

      <EditText 
       android:id="@+id/problem_name" 
       android:layout_height="wrap_content" 
       android:hint="@string/feedbackname" 
       android:inputType="textPersonName" 
       android:layout_width="fill_parent"> 
      </EditText>   

      <EditText 
       android:id="@+id/problem_text" 
       android:layout_height="wrap_content" 
       android:hint="@string/feedbackbody" 
       android:inputType="textMultiLine" 
       android:lines="5" 
       android:layout_width="fill_parent"> 
      </EditText> 

      <Button 
       android:id="@+id/button_send_feedback" 
       android:layout_height="wrap_content" 
       android:text="@string/feedbackbutton" 
       android:onClick="sendFeedback" 
       android:layout_width="fill_parent"> 
      </Button>    

     </LinearLayout> 
    </ScrollView> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="First, add the problem you want to solve!" 
     /> 

    <TextView 
     android:id="@+id/add_problem_text"  
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Add a Problem You Want To See Solved" 
     />  

     <Button 
     android:id="@+id/add_problem_button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Add a Problem" 
     /> 

     <Button 
     android:id="@+id/browse_problems_button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Browse Problems" 

     /> 
     <Button 
     android:id="@+id/search_problems_button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Search Problems" 
     /> 

     <Button 
     android:id="@+id/my_problems_button"   
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="View My Problems" 
     />  
    </LinearLayout> 
</LinearLayout> 
+0

谢谢 - 咄我 - 新手错误:) – GeekedOut 2012-02-20 17:08:52