TextView不适合ScrollView

时间:2017-07-03 07:35:35

标签: android android-layout textview scrollview

我遇到TextView与ScrollView不匹配的问题......

这是我的代码:

<ScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/scrollViewSlide"
            tools:ignore="UselessParent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center">

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:id="@+id/txtPassage"
                    android:textAlignment="center"
                    android:textIsSelectable="true"
                    android:textColor="#ffffff"
                    android:textSize="15sp"
                    tools:ignore="UnusedAttribute" />

            </LinearLayout>

        </ScrollView>

s显示并且是错误的(更好的说法就是隐藏了大约5个第一行)enter image description here

2 个答案:

答案 0 :(得分:2)

试试这个

ACT_DTL_ID  USER_ID   ACTIVITY_TYPE   ACTIVITY_TIME
0000000003  DOC000035   LOGIN           03-07-17 12:35:39.000000000 PM
0000000004  DOC000035   LOGOUT          03-07-17 12:41:07.000000000 PM
0000000005  DOC000035   LOGIN           03-07-17 12:41:28.000000000 PM
0000000006  DOC000035   LOGOUT          03-07-17 12:50:35.000000000 PM

答案 1 :(得分:1)

使用此代码,这将有助于

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/li1"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:text="Hello"
            android:layout_height="match_parent" />
    </LinearLayout>

</ScrollView>