Horizontal ScrollView in fragment Android

2019-09-21 14:50发布

I would like to make my ScrollView filling out the full layout of a fragment and scrolling horizontally, not vertically.

How can I achieve that?!

Like the album covers

Thanks

2条回答
我只想做你的唯一
2楼-- · 2019-09-21 15:34

Its not vertically, it is horizontally

<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>

查看更多
smile是对你的礼貌
3楼-- · 2019-09-21 15:41

You have to set the scrollview to

    android:fillViewport="true"

Below is the complete code

 <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>
查看更多
登录 后发表回答