Horizontal ScrollView in fragment Android

旧时模样 提交于 2019-12-13 10:38:00

问题


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


回答1:


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>




回答2:


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>


来源:https://stackoverflow.com/questions/30476690/horizontal-scrollview-in-fragment-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!