我在scrollview中使用parchment 水平滚动的机会插入以下方法:
ScreenView.setOnTouchListener(new ListView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
v.onTouchEvent(event);
return true;
}
});
这适用于滚动,仅适用于此。
但该方法不适用于setsetOnItemClickListener。
我不得不放置按钮,但看起来很糟糕:
btnslideShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent slideShow = new Intent(getApplicationContext(), FullImageActivity.class);
slideShow.putExtra("links", links);
startActivity(slideShow);
}
});
我的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:scrollbars="none">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/logo"
android:layout_width="85dp"
android:layout_height="85dp" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/logo"
android:ellipsize="end"
android:gravity="left|top"
android:maxLines="3" />
<mobi.parchment.widget.adapterview.listview.ListView
xmlns:parchment="http://schemas.android.com/apk/res/intermediasoft.com.hotlistplaymarket"
android:id="@+id/screenlist"
android:layout_width="match_parent"
android:layout_height="200dp"
android:clipToPadding="true"
android:drawSelectorOnTop="false"
parchment:orientation="horizontal"
parchment:snapPosition="start"
android:layout_below="@+id/logo"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/screenlist"
android:linksClickable="true" />
<ImageButton
android:id="@+id/slideShow"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerCrop"
android:layout_below="@+id/screenlist"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="@drawable/full_screen" />
</RelativeLayout>
</ScrollView>
setOnItemLongClickListener有效,但此方法并不总是清晰。
告诉我如何更改setOnTouchListener以处理setOnItemClickListener