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