Android 我如何克服文本视图不适合屏幕的问题,以及将其他内容推出屏幕的问题?

Android 我如何克服文本视图不适合屏幕的问题,以及将其他内容推出屏幕的问题?,android,xml,android-layout,textview,android-xml,Android,Xml,Android Layout,Textview,Android Xml,我正在尝试构建一个简单的表单,我想在顶部添加一个注释/标题/标题来显示消息。我已经试过了,但是文字已经从屏幕上消失了,下面的内容也被删除了。我该如何应对 这是my layout.xml,它位于pastebin上: 我不确定在没有看到照片的情况下我是否完全理解你的问题,但我看了一下你的粘贴箱。一般来说,在您的情况下,ScrollView布局中的根视图的宽度和高度可能都应该有match_parent或fill_parent,否则您可能会看到一些奇怪的渲染,其中没有布局覆盖屏幕的空白区域,或者出现一些

我正在尝试构建一个简单的表单,我想在顶部添加一个注释/标题/标题来显示消息。我已经试过了,但是文字已经从屏幕上消失了,下面的内容也被删除了。我该如何应对

这是my layout.xml,它位于pastebin上:


我不确定在没有看到照片的情况下我是否完全理解你的问题,但我看了一下你的粘贴箱。一般来说,在您的情况下,ScrollView布局中的根视图的宽度和高度可能都应该有match_parent或fill_parent,否则您可能会看到一些奇怪的渲染,其中没有布局覆盖屏幕的空白区域,或者出现一些奇怪的滚动行为

特别注意他在表格行及其子行上使用的属性,以实现他想要的布局

至于你想显示一些标题信息的问题,我可以想出两个选择

如果希望它们在TableLayout滚动时固定在屏幕顶部,请创建LinearLayout作为布局的根视图,并将其方向设置为垂直。将标题作为第一个子项添加到此LinearLayout,将滚动视图作为第二个子项。 如果希望标题信息与表格一起滚动,请将ScrollView保留为根视图,并再次创建一个线性布局,垂直方向是它的唯一直接子级。将标题信息添加为LinearLayout的第一个子项,将TableLayout添加为第二个子项。
希望这有帮助。如果你发布了一张你现在看到的屏幕截图,以及你想要的布局模型,这将有助于隔离你遇到的问题,并帮助我们在社区提供支持。

你是否同时发布了android:layout\u height=wrap\u content和android:layout\u width=wrap\u content。一个可能有用的想法…嗨,谢谢。是的,我已经把它放在TextView和封装TableRow中了。它解决了屏幕外的文本问题,但其他小部件仍然没有了。这很好,可以尝试将这两行添加到TextView、EditText、微调器和按钮标记中。我想你不需要把它放在桌子上,但我不确定。我对Android还是相当陌生,但我认为每个可见组件都必须有这两个属性,但我不是100%确定。
<TableLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:shrinkColumns="1"
   android:stretchColumns="1" >

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp"
       android:layout_width="match_parent" >
        <TextView
           android:layout_width="match_parent"
           android:text="You can only add a spot based on your current location" />

    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Name:" />
        <EditText android:id="@+id/name" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Address:" />
        <EditText android:id="@+id/addr" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Type:" />
        <Spinner
           android:id="@+id/spinnerType"
           style="@style/AppBaseTheme"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:entries="@array/types_array"
           android:prompt="@string/types_prompt" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Terrain:" />
        <Spinner
           android:id="@+id/spinnerTerrain"
           style="@style/AppBaseTheme"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:entries="@array/ratings_array"
           android:prompt="@string/ratings_prompt" />
    </TableRow>

    <TableRow>
        <TextView android:text="Difficulty:" />
        <Spinner
           android:id="@+id/spinnerDifficulty"
           style="@style/AppBaseTheme"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:entries="@array/ratings_array"
           android:prompt="@string/ratings_prompt" />
    </TableRow>

   <TableRow
       android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" >
        <TextView android:text="Description:" />
        <EditText
           android:id="@+id/desc"
           android:gravity="top"
           android:inputType="textMultiLine"
           android:lines="2"
           android:maxLines="2"
           android:scrollHorizontally="false" />
    </TableRow>

    <Button
       android:id="@+id/save"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:text="Save"
                    android:layout_marginBottom="2sp"
       android:layout_marginTop="2sp" />
</TableLayout>