我为ListView实现了一个自定义ListItem。 ListItem看起来像这样:
<?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>
这看起来很棒并且按预期执行,除非我打开SlidingDrawer并尝试滚动TextView中包含的文本。
TextView看起来得到了焦点,因为我看到TextView的滚动条出现片刻,但是ListView似乎抓住焦点并且整个列表开始滚动。
我是否需要实现自定义ListView来对其进行排序或是快速修复?我尝试了同样的方法,但使用了一个确实有效的HorizontalScrollScrollView,但这可能是因为ListView对水平滚动事件没有任何作用。
任何帮助表示赞赏
答案 0 :(得分:1)
在ScrollView上设置触控侦听器
OnTouchListener childScroll = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.getParent().requestDisallowInterceptTouchEvent( true);
return false ;
}
};