【问题标题】:TextView in a LinearLayout that is set in a ScrollVew getting squeezed在 ScrollVew 中设置的 LinearLayout 中的 TextView 被挤压
【发布时间】:2018-03-01 16:37:07
【问题描述】:

在这里发疯了,(为了清楚起见:我在 stackoverflow 上查看了有关“滚动视图不起作用”的所有问题,但没有一个有帮助)。以下是我正在尝试做的简短版本

 <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 内重复多次,我希望它水平滚动。我得到的是:

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

【问题讨论】:

  • 你想要什么?你的意思是你的LinearLayout 的orientation 是vertical 吗?或者你可能想要一个HorizontalScrollView 来代替?
  • @MikeM。我希望能够水平滚动 - 抱歉那里不清楚
  • ScrollView 垂直滚动。你想要一个HorizontalScrollView。

标签: android xml scrollview


【解决方案1】:

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

【讨论】:

  • 真是个该死的小姐-感觉这将是一件非常简单的事情-谢谢你们(y)
【解决方案2】:

因为你有 n 个 textViews 更好用

具有水平布局管理器的回收视图,因为它不会一次性创建所有文本视图的记忆

或者,

您可以使用 Horizo​​ntalScrollView 水平滚动它们..

ScrollView 垂直滚动

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-09
    • 2020-10-15
    • 1970-01-01
    • 2013-03-24
    • 2011-12-18
    • 1970-01-01
    • 1970-01-01
    • 2015-08-19
    相关资源
    最近更新 更多