Vertical Scrolling Text In a ListItem?
-
02-07-2021 - |
Question
I have implemented a custom ListItem for my ListView. The ListItem looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlOfferRoot"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:padding="5dp"
android:background="@color/white">
<RelativeLayout
android:id="@+id/rlOfferDetails"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000">
<LinearLayout
android:id="@+id/llOfferRoot"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:orientation="vertical"
android:background="@color/orange">
<ImageView
android:id="@+id/imgOfferImage"
android:layout_width="fill_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout
android:id="@+id/menuDrawerLayer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:layout_gravity="bottom">
<SlidingDrawer
android:id="@+id/sdOfferDetails"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignBottom="@id/imgOfferImage"
android:content="@+id/drawerButtons"
android:handle="@+id/slideHandleButton"
android:topOffset="-50dp">
<Button
android:id="@+id/slideHandleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/arrowup"/>
<RelativeLayout
android:id="@+id/drawerButtons"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80000000">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:padding="10dp"
android:focusable="true">
<TextView
android:id="@+id/txtOfferDetails"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/white"
android:text="This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text end
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text end
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text end
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text end
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text end
This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text This is some text end"/>
</ScrollView>
</RelativeLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
This looks great and performs as expected except when I open my SlidingDrawer and try to scroll through the text contained in the TextView.
The TextView looks to get focus as I see the scrollbar for the TextView appear for a moment, but then the ListView seems to grab the focus and the whole list starts to scroll.
Am I going to need to implement a custom ListView to sort this or is their a quick fix? I attempted the same as above but used a HorizontalScrollScrollView which did work, but this is probably because the ListView does nothing with the Horizontal scroll events.
Any help appreciated
Solution
Set on touch listner on your ScrollView
OnTouchListener childScroll = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.getParent().requestDisallowInterceptTouchEvent( true);
return false ;
}
};