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)是我需要刷新的內容。 –