【问题标题】:Horizontal ScrollView in fragment Android片段Android中的水平滚动视图
【发布时间】:2015-08-09 04:45:27
【问题描述】:

我想让我的 ScrollView 填充片段的完整布局并水平滚动,而不是垂直滚动。

我怎样才能做到这一点?!

Like the album covers

谢谢

【问题讨论】:

  • 你用过哪个Scrollview?你能分享一下你做了什么吗?

标签: android scrollview vertical-alignment


【解决方案1】:

您必须将滚动视图设置为

    android:fillViewport="true"

下面是完整代码

 <ScrollView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/myscrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">
 </ScrollView>

【讨论】:

    【解决方案2】:

    不是垂直的,是水平的

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    
        <HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
            // Add your ImageButtons
        </LinearLayout>
    </HorizontalScrollView>
    

    【讨论】:

    • 如果我现在将 ImageButtons 之类的元素放在此 LinearLayout 中,它们将垂直滚动?
    • 它只是水平滚动而不是垂直滚动(从左到右)
    • 兄弟,垂直是上下,水平是左右。你需要哪一个?
    • 检查我更新的答案。如果这是您需要的答案,请接受。
    • 请稍等,我可以试一试,但它很可能是正确的!
    猜你喜欢
    • 2012-10-05
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多