在ScrollVew中设置的LinearLayout中的TextView被挤压

问题描述 投票:-1回答:2

在这里疯狂的这个,(只是要清楚:我在stackoverflow上查看了关于“scrollview不工作”的所有问题,但没有一个帮助)。以下是我正在尝试做的简短版本

 <ScrollView
    android:id="@+id/week_View"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Monday" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Monday" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Monday" />.....
        .............
   </LinearLayout>
</ScrollView>

如果没有清除textview会在linearLayout内重复多次,我想让它水平滚动。我得到的是:

enter image description here

您会看到最后的textView被“挤压”,其余的文本视图甚至都没有显示,并且scrollview不会向左或向右移动。我做错了什么? (scrollview包含在RelativeLayout中)。

android xml scrollview
2个回答
2
投票

ScrollViews始终是垂直的,这意味着它们会上下移动。请改用Horizo​​ntalScrollView。


1
投票

因为你有很多textViews,所以最好使用它

使用水平布局管理器的recyclelerview,因为它不会一次性创建所有textview的记忆

要么,

你可以使用horizo​​ntalScrollView水平滚动它们。

ScrollView垂直滚动

© www.soinside.com 2019 - 2024. All rights reserved.