2011-05-07 15 views
1

我試圖將GestureOverlay下的視圖方向設置爲無。此時我可以將方向設置爲垂直或水平。但是,對於我的應用程序,我不想要,這需要設置爲無。如何將手勢疊加下方的視圖方向設置爲「無」

article爲手勢API,它說以下內容:

orientation: indicates the scroll orientation of the views underneath. In this case the list scrolls vertically, which means that any horizontal gestures (like action_delete) can immediately be recognized as a gesture. Gestures that start with a vertical stroke must contain at least one horizontal component to be recognized. In other words, a simple vertical line cannot be recognized as a gesture since it would conflict with the list's scrolling.

和上面,它示出了該代碼段,顯示所述機器人:取向爲垂直。

<android.gesture.GestureOverlayView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/gestures" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 

android:gestureStrokeType="multiple" 
android:eventsInterceptionEnabled="true" 
android:orientation="vertical"> 

網上搜索後,我發現這段代碼的使用android:orientation="none"

於是,我就實現了我的GestureOverlay這一個Android主題,但是當我用這一點,只是在XML產生這個錯誤文件:錯誤:錯誤:不允許字符串類型(在'orientation'中,值爲'none')。我的代碼如下所示:

<android.gesture.GestureOverlayView 
android:id="@+id/gestures_alpha" 
android:layout_width="fill_parent" 
android:layout_height="0dip" 
android:layout_weight="1.0" 
android:gestureStrokeType="multiple" 
android:fadeOffset="2000" 
android:orientation="none"/> 

可能有人讓我知道,如果有一個變通,或者如果這是一個SDK版本問題。我使用SDK版本7(2.1.1)進行編碼。

感謝

+0

我發現一些更多的信息[這裏](http://gitorious.org/replicant/android_frameworks_base/commit/d98418db26a3af03d3c981efe3c4d5f6215327be) 我不知道這個代碼是如何工作雖然 – Navigatron 2011-05-07 18:46:18

回答

1

android:orientation="none"選項是Replicant project的一部分,而不是適用於標準的Android版本。總之,唯一的選擇是橫向和縱向,對不起。

+0

那是不幸的,我希望能有某種解決辦法。不管怎麼說,還是要謝謝你! – Navigatron 2011-05-08 13:27:39

0

它看起來像你想要使用GestureOverlayView識別水平和垂直手勢。這是解決方案:

gestureOverlayView.setOrientation(GestureOverlayView.ORIENTATION_VERTICAL); 
gestureOverlayView.setGestureStrokeAngleThreshold(90); 
相關問題