Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ScrollView在TextView中剪切文本_Java_Android_Scrollview - Fatal编程技术网

Java ScrollView在TextView中剪切文本

Java ScrollView在TextView中剪切文本,java,android,scrollview,Java,Android,Scrollview,我的ScrollView布局有问题: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/a

我的ScrollView布局有问题:

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

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_gravity="center_horizontal|center_vertical"
        android:id="@+id/editRelativeLayout"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <TextView
            android:id="@+id/typeTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </LinearLayout>
</ScrollView>


问题是当我在TextView中有很多文本要显示时,TextView2就会消失。。。知道如何修复吗?

LinearLayout
中的android:layout\u height更改为
wrap\u content
我已经解决了删除行的问题:

android:layout_gravity="center_horizontal|center_vertical"

我知道,如果你正在制作和编辑文本框,有一个选项可以使其多行,这样,如果他们溢出框,它将滚动与它。我相信TextView有一个类似的选项;在android xml creator的属性端,应该有一个属性来帮助您在不被切断的情况下显示。是的,应该是包装内容

当我刚刚偶然发现同样的问题时,我找到了一个解决方案,允许您保持文本居中,但避免剪切错误:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"         // Automatic ScrollView height
            android:layout_gravity="center_vertical">    // Center ScrollView vertically

        <TextView android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:gravity="center_horizontal" /> // Center TextView content horizontally

</ScrollView>
//垂直居中滚动视图
//居中文本水平查看内容

我不明白它是如何变得“不可见”的,无论第一个文本视图有多长,你都应该能够向下滚动并看到它。是的,我可以向下滚动,但我不能向上滚动以看到文本视图2,所以你只能向一个方向滚动?这有点难以解释。这样说吧:我有一个文本视图2,上面有5行,下面有一个文本视图,上面有20行。当我创建这个布局时,我看到文本视图的第五行,我可以滚动到开始(第五行)到结束,反之亦然,但我看不到文本视图的第一行或整个文本视图2,我希望有办法理解我写的内容。。