Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: HorizontalScrollView inside ScrollView

Tags:

java

android

I have multiple HorizontalScrollViews inside a ScrollView. Horizontal scroll isn't smooth at all. I have to scroll almost perfectly horizontally for scrolling to work. Is there a simple fix to tweak this ??? Thanks!

Multiple HorizontalScrollViews inside a single ScrollView

like image 766
vladexologija Avatar asked Aug 22 '12 14:08

vladexologija


People also ask

Can scroll horizontally Android?

The android. widget. HorizontalScrollView class provides the functionality of horizontal scroll view. HorizontalScrollView is used to scroll the child elements or views in a horizontal direction.

What is nested scroll view in Android?

NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

What is the difference between ScrollView and horizontal ScrollView?

ScrollView and HorizontalScrollView has same attributes, the only difference is scrollView scroll the child items in vertical direction while horizontal scroll view scroll the child items in horizontal direction.

How do you add a scroll view in linear layout?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In this above code, we have declare Linear layout as parent and added Vertical Scroll view.


1 Answers

You can use Recycler view with Staggered layout manager

 StaggeredGridLayoutManager  staggeredGridLayoutManager = new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.HORIZONTAL);

 RecyclerViewAdapter recyclerViewAdapter = newRecyclerViewAdapter(this);

 recyclerView.setAdapter(recyclerViewAdapter); //Don't miss to initialize your adapter
like image 157
Yousef Zakher Avatar answered Nov 01 '22 23:11

Yousef Zakher