ScrollView杀死了我的android应用程序,而我没有';我不了解有关表视图的某些内容

ScrollView杀死了我的android应用程序,而我没有';我不了解有关表视图的某些内容,android,xml,android-layout,scrollview,Android,Xml,Android Layout,Scrollview,我正在为我的Nexus7平板电脑编写一个小应用程序,我有一个奇怪的错误。据我所知,以下xml <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"

我正在为我的Nexus7平板电脑编写一个小应用程序,我有一个奇怪的错误。据我所知,以下
xml

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
  <ScrollView>
    <TableRow
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:padding="2dip">
      <EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:hint="name"
      android:inputType="text"
      android:textSize="20sp"/>
      <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textSize="20sp"
      android:text="smells more like prey than a hunter."/>
    </TableRow>
    <TableRow
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:padding="2dip">
      <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textSize="20sp"
      android:text="The spirits spoke to me of a great danger that follows"/>
      <EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:hint="name"
      android:inputType="text"
      android:textSize="20sp"/>
    </TableRow>
  </ScrollView> 

</TableLayout>

应该生成一个两行的可滚动应用程序,每行都有一个写有灰色
名称
的文本字段,文本环绕在其周围,并在文本之前或之后写入附加文本,以尝试填充屏幕。然而,当我编译此文件时,应用程序崩溃(
,不幸的是,它已经停止了
)。如果删除
ScrollView
属性,则两行的长度相同,在横向模式下,
EditText
占用每行一半的空间。在纵向模式下,第一行仅包含
EditText
字段,第二行仅包含
TextView
字段。我觉得这张桌子试图把两条线放在同一长度上,但我不明白为什么

我怎样才能解决这个问题? 评论:

我使用的是generate by库结构,我只在平板电脑上编译代码

将表格布局全部放在滚动视图中。scrollview只能有一个直接子对象,但该子对象可以有多个子对象!此外,您还需要scrollview的高度和宽度

这里


应该为美国工作


尝试上面的布局,而不是你的,让我知道如果它有帮助。说实话,我认为您需要一个listview和一个适配器…

这是可行的,但我有一些问题。大多数情况下,我希望将大部分线条居中,并将其他线条向左对齐。据我所知,``列表视图“不允许使用更复杂的线条样式,但我仍然对它感到困惑,因为它可以满足您的需要,但对于这里。。。改变文本视图的重心,使其向左对齐、向左对齐或完全移除。使用listview,您可以创建一个自定义适配器,无论您想要什么,当您创建具有相同布局但具有不同属性的重复项时,您可能是最好的。xml也少了很多,谢谢。我试着在指南中搜索
ListView
adapter
,它们不是文本列表,我找不到。我在哪里可以找到这方面的数据?
<?xml version="1.0" encoding="utf-8"?>


<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
    <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
      <EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:hint="name"
      android:inputType="text"
      android:textSize="20sp"/>
      <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
        android:gravity="center"
      android:textSize="20sp"
      android:text="smells more like prey than a hunter."/>
    </LinearLayout>
  <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
   <EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:hint="name"
      android:inputType="text"
      android:textSize="20sp"/>

      <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textSize="20sp"
      android:gravity="center"
      android:text="The spirits spoke to me of a great danger that follows"/>

  </LinearLayout>

</TableLayout>
</ScrollView>