I have a RecyclerView
<android.support.v7.widget.RecyclerView
android:id="@+id/activityRecicler"
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="wrap_content"
app:stackFromEnd="true"
/>
And I have a row layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/description"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/solutions"/>
</LinearLayout>
And the wrap content work, but my problem is that TextView
with id description It could be very long and so, I would have a Scroll for this TextView.
How could I do this?
Change your layout XML to:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:id="@+id/childScroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
<TextView
android:id="@+id/solutions"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
And then in your activity:
activityRecicler.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
findViewById(R.id.childScroll).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScroll.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With