为什么 TextView 与 ScrollView 相交?

Why TextView intersects with ScrollView?

为什么我的 TextView 与 Activity 右侧的 ScrollView 相交,如何解决?

这是我的 Activity 的屏幕截图。

这是我 Activity 的代码 XML。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginTop="16dp"
    android:orientation="vertical">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="@string/rules"
                android:textSize="@dimen/text_font_tall"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="start"
                android:text="@string/rules_text"
                android:textSize="@dimen/text_font_medium" />

        </LinearLayout>
    </ScrollView>
</LinearLayout>

使用与第一个 LinearLayout 相同的方式为第二个 LinearLayout 使用边距。

android:layout_margin="16dp"

顺便说一句:只要所有边距的参数都相同(layout_marginTop、layout_marginBottom、layout_marginLeft 和 layout_marginRight),您可以只使用一个属性:layout_margin

BTW2:你真的需要父LinearLayout吗?你可以这样试试:

<ScrollView>
    <LinearLayout>
        <TextView/>
        <TextView/>
    </LinearLayout>
</ScrollView>