MapView inside scrollview is not scrolling vertically which is inside Fragment - android

I have one Fragment and in that I have taken mapview which is inside ScrollView.
While Scrolling the mapview It doesn't scrolling vertically due to it is inside ScrollView, But It scrolls horizontally.
How to avoid this Problem ?

You can add this line on your scrollview in order to allow only vertical scrolling.
android:scrollbars="vertical"

Related

How to delegate scroll of RecycleView to ScrollView

I have a RecyclerView inside ScrollView. I want RecyclerView to start scrolling itself only after it reached a top of the screen, and while it isn't it should scroll his parent ScrollView. How to achieve this behavior?
use widget nestedscrollview or
recyclerview scroll display and scrollview enable
recyclerView.setNestedScrollingEnabled(false);

Horizontal RecyclerView inside ScrollView: how to get focus when vertical scrolling?

I have a ScrollView with multiple horizontal RecyclerView. The problem is this:
When I scroll vertically to navigate into my app and I touch on a recyclerview to scroll horizontally, the focus remain on the scrollview and I can't scroll horizontally. I have to release the finger and touch again in order to scroll vertically. I'd like to give proprity to the recyclerview, so I can scroll horizontally without stopping the vertical scroll.
I tried multiples solutions:
editing some parameters in the xml of the recyclerview and its container (focusable, focusableintouchmode, descendantFocusability,nestedscrollingenabled)
adding an ontouchlistener and intercepting the motionevent, both in scrollview and recyclerview
This problem is present using both ScrollView and NestedScrollview and using both RecyclerView and ListView
Thanks for your help
This problem because of recyclerView has default focus.
Just Add this
android:descendantFocusability="blocksDescendants"
to your immediate layout of scrollView.

Android: ScrollView vs NestedScrollView

What is the difference between ScrollView and NestedScrollView? Both of them, extend FrameLayout. I want to know in depth pros and cons of both of them.
NestedScrollView as the name suggests is used when there is a need for a scrolling view inside another scrolling view. Normally this would be difficult to accomplish since the system would be unable to decide which view to scroll.
This is where NestedScrollView comes in.
In addition to the nested scrolling NestedScrollView added one major functionality, which could even make it interesting outside of nested contexts: It has build in support for OnScrollChangeListener. Adding a OnScrollChangeListener to the original ScrollView below API 23 required subclassing ScrollView or messing around with the ViewTreeObserver of the ScrollView which often means even more work than subclassing. With NestedScrollView it can be done using the build-in setter.
Other than the advantages listed in the answers given, one more advantage of NestedScrollView over ScrollView is its compatibility with CoordinatorLayout. The ScrollView does not cooperate with the CoordinatorLayout. You have to use NestedScrollView to get "scroll off-screen" behaviour for the toolbar.
Toolbar will not collapse with Scrollview as child of CoordinatorLayout
NestedScrollView
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.
https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html
ScrollView
Layout container for a view hierarchy that can be scrolled by the
user, allowing it to be larger than the physical display. A
ScrollView is a FrameLayout, meaning you should place one child in it
containing the entire contents to scroll; this child may itself be a
layout manager with a complex hierarchy of objects
https://developer.android.com/reference/android/widget/ScrollView.html
NestedScrollView is just like ScrollView, but in NestedScrollView we can put other scrolling views as child of it, e.g. RecyclerView.
But if we put RecyclerView inside NestedScrollView, RecyclerView's smooth scrolling is disturbed. So to bring back smooth scrolling there's trick:
ViewCompat.setNestedScrollingEnabled(recyclerView, false);
put above line after setting adapter for recyclerView.
I think one Benefit of using Nested Scroll view is that the cooridinator layout
only listens for nested scroll events. So if for ex. you want the toolbar to scroll down when you scroll you content of activity, it will only scroll down when you are using nested scroll view in your layout. If you use a normal scroll view in your layout, the toolbar wont scroll when the user scrolls the content.
<androidx.core.widget.NestedScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
// your Layout xml code
</androidx.core.widget.NestedScrollView>

Preventing Scrollable layout when using webview/mapview

I am stuck in one situation...I have my parent layout as a scrollable layout. Inside this layout, I have a webview and a tablelayout. Some data are inflated in this scrollable layout.
My question is, my vertical scrollable functionality seems to be disabled since my scrollable layout already have the functionality. I hardly can scroll up and down inside the webview. And same situation for Mapview. I can only zoom in and zoom out using horizontal gesture. I wonder if there is any way to disable the scroll functionality only when I zoom in/out, scroll up/down in mapview/webview. Thank you so much.

Adding dynamic content to ScrollView causes jerk to bottom

I have implemented my own ScrollView that detects when the position of the ScrollView is close to the bottom and add views as necessary. The problem is when I add views to the LinearLayout inside of the ScrollView the scroll jerks to the bottom where I added some views. Is there anyway to add views to a LinearLayout inside a ScrollView that will not cause this behavior?
Thanks
Edit: This seems to only happen while scrolling. I have a case where I add views to the same ScrollView but by clicking a button rather than scrolling and I don't have the jerking problem. The new views just get added to the bottom of the LinearLayout being scrolled.

Categories

Resources