android - TextView 不适合 ScrollView

标签 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.th 显示的是 false (更好的说法是,大约 5 个第一行被隐藏)enter image description here

最佳答案

试试这个

    <ScrollView
    android:layout_width="match_parent"
    android:fillViewport="true"
    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="Hellofgbjfdkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkhbhbghbuuuuuuuuuuuuuuuubfiiiiiiiiiibigyygfjjjjjjjjjjjjjjjjjjjjjjjjjj\nfjgggggggggggggggg\ngfggggggggggggggggggg\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\njgjijhijghijgfhjgfhjigfjhijgfhjgi
            jfdjgkfjd\nkkgkfgklfkgfg"
            android:layout_height="match_parent" />
    </LinearLayout>

</ScrollView>

关于android - TextView 不适合 ScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44880084/

相关文章:

android - 在 RecyclerView 中设置计数器

android - 在渲染到布局之前获取 TextView 的高度

android - 监控设备上的应用程序以检测崩溃

当应用程序在后台时,Android 第二次推送通知有效负载数据未接收到额外内容

android - 水平 ListView 选择器

java - 布局权重不起作用 CardView

android - Firemonkey 安卓 NFC 适配器

android - 微调偏好? (如何在首选项屏幕中嵌入 Spinner)

android - TextView:在省略号后添加文本或更改省略号字符

android - 在android中将值设置为textview