Scrollview Inside Scrollview

Android scrollview inside another scrollview doesn't scroll

You should use NestedScrollView.

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- -->
</android.support.v4.widget.NestedScrollView>

ScrollView Inside ScrollView

Is this close enough?

You should never use a
HorizontalScrollView with a ListView,
since ListView takes care of its own
scrolling. Most importantly, doing
this defeats all of the important
optimizations in ListView for dealing
with large lists, since it effectively
forces the ListView to display its
entire list of items to fill up the
infinite container supplied by
HorizontalScrollView.

http://developer.android.com/reference/android/widget/HorizontalScrollView.html

UPDATE:

Since you may be forced to use a two dimensional scrollview, you may consider using this:
Internet archive of blog.gorges.us/2010/06/android-two-dimensional-scrollview/

I haven't used this but it may be a reasonable approach.

NestedScrollView inside a ScrollView is not scrolling for API17

Try changing it into this format and see if it works:

<NestetScrollView>

<Other Views/>
<Other Views/>

<ScrollView>

<CustomTextView/>

</ScrollView>

</NestetScrollView>

ReactNative ScrollView inside a View

don't forget to import scrollview from react native like this :import {
Text,
View,
ScrollView
} from 'react-native';

    render() {        return (          <View style={styles.container}> // style in firstview            <View>              <Text>Top</Text>            </View>            <ScrollView contentContainerStyle={styles.Scroll}>// and give style in scrollview              <Text>Line 1</Text>              <Text>Line 2</Text>              <Text>Line 3</Text>              <Text>Line 4</Text>              <Text>Line 5</Text>              <Text>Line 6</Text>              <Text>Line 7</Text>            </ScrollView>          </View>        );      }}
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'orange', justifyContent: 'center', // alignItems: 'center' }, Scroll: { height: 1000, paddingVertical: 30, }});

Android list view inside a scroll view

For any Child view to scroll inside a ScrollView. Anything like ListView, RecyclerView, etc. You just have to replace ScrollView with androidx.core.widget.NestedScrollView in your current xml and then magic happens.

Below is a sample xml code :

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp"
android:paddingBottom="20dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Recycler View inside a Scroll View"
android:textColor="@color/black"
android:textSize="@dimen/_20sp"
android:textStyle="bold" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Below is a Recycler View as an example."
android:textSize="16sp" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@id/et_damaged_qty" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="This textview automatically goes below the Recycler View."
android:textSize="16sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>

Now you can get rid of all the ugly hacks you did to get around with nested scrolling.

scrollview inside a fragment is not scrolling

Add this property in ScrollView

android:isScrollContainer="false"

and Make LinearLayout to

wrap_content

ScrollView inside RecyclerView won't scroll

I solved it by adding a line to rafsanahmad007's solution:

    ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView1);
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// Disallow the touch request for parent scroll on touch of child view

view.getParent().requestDisallowInterceptTouchEvent(false);
view.onTouch(motionEvent);
return true;
}
});

I'm not sure that's how View.onTouch is called on Java, as I'm developing with Xamarin.Android (C#). It should be pretty similar.

Scroll View inside Nested Scroll View does't work

It's work now, just remove scrollview and add in listview android:nestedScrollingEnabled="true".



Related Topics



Leave a reply



Submit