0
我正试图在布局上实施滑动手势。下面是XML:“复杂”布局上的滑动事件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ViewSwitcher
android:id="@+id/switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blister_background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum=".9" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".3"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="@+id/imgOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".5"
android:src="@drawable/yellow" />
<ImageView
android:id="@+id/imgTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".5"
android:src="@drawable/yellow" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".3"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="@+id/imgThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".5"
android:src="@drawable/yellow" />
<ImageView
android:id="@+id/imgFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".5"
android:src="@drawable/yellow" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".3"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="@+id/imgFive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".5"
android:src="@drawable/yellow" />
<ImageView
android:id="@+id/imgSix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".5"
android:src="@drawable/yellow" />
</LinearLayout>
</LinearLayout>
</ViewSwitcher>
</RelativeLayout>
在Java代码中,我设置了setOnTouchListener
为ViewSwitcher
,返回由GestureDetector
返回boolean值。所以我重写了onFling
方法,实际上它起作用。唯一的问题是,如果我没有触摸Imageviews,它就会起作用。
的ImageViews被监听onClick
事件。
所以,我怎么可以刷卡上Imageviews和曾记得onFling
方法中的代码?
我试图设置onTouchListener
即使他ImageViews但他们不赶上onCLick
事件了。
首先'ViewSwitcher'是 “'ViewAnimator'该**两个视图之间切换**”。如果你想要更多的视图,你应该使用'ViewFlipper'。 该视图内唯一应该是被轻扫的内容。如果你这样做,你就不会有问题。 –
其实我需要在两个视图之间切换。内容(六个ImageViews)是我需要刷新的内容。 –