I have a bottom sheet dialog with 2 nestedscrollview
, the outer one wrap the entire view, the inner one wrap a single textview
, I have 2 problems:
1. the the inner one can scroll only down, as you can see in the gif:
I need to make the inner nestedscrollview
scrollable in both direction and the outer nestedscrollview
scrollable when I drag outside the inner one, how can I do it?
2.
I need to make the inner nestedscrollview
to wrap text, tried with constraints but not working, wrap_content make the entire textview
to be shown, making the scrollview
a simple textview
.
How can I do it?
This is my XML code:
<androidx.core.widget.NestedScrollView
android:id="@+id/outer_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewSwitcher
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/inner_scrollview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
android:textColor="@color/white"
android:textSize="25dp"
</androidx.core.widget.NestedScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</ViewSwitcher>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
After Some R&D at my End I have Finalised the XML Layout, Its Working For Me.
Actually the issue was the Wrong layout Designing. Grab the Latest Changes from Below.
<androidx.core.widget.NestedScrollView
android:id="@+id/outer_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewSwitcher
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/inner_scrollview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="200dp"
android:nestedScrollingEnabled="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
android:textColor="@color/white"
android:textSize="25dp"></TextView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</ViewSwitcher>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
Apply this layout XML and Let me know if anything Required more.