0
내 애플리케이션에 좌우 제스처를 구현하십시오. 그것이 올바른안드로이드 응용 프로그램에서 제스처 지원을 구현하는 방법은 무엇입니까?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="10sp">
<TextView android:id="@+id/movie_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="text"
android:paddingTop="8sp"
android:paddingBottom="16sp"
android:textSize="16sp"
android:textColor="#FFFFFF"
android:textStyle="bold"/>
<ImageView android:id="@+id/movie_poster"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"/>
<TextView android:text=""
android:id="@+id/movie_description"
android:layout_height="wrap_content"
android:textSize="16sp"
android:paddingTop="16sp"
android:paddingBottom="16sp"
android:layout_width="fill_parent"/>
<Button android:id="@+id/confirm"
android:text="@string/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.gesture.GestureOverlayView
android:id="@+id/movie_gestures"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0" />
</LinearLayout>
</ScrollView>
가 : 여기
내 레이아웃입니까? 응용 프로그램은 제스처에 반응하지 않습니다.public class MovieView extends Activity implements OnGesturePerformedListener {
private GestureLibrary mLibrary;
@Override
protected void onCreate(Bundle savedInstanceState) {
...
// gestures
mLibrary = GestureLibraries.fromRawResource(this, R.raw.spells);
if (!mLibrary.load()) {
finish();
}
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.movie_gestures);
gestures.addOnGesturePerformedListener(this);
}
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
if (predictions.size() > 0 && predictions.get(0).score > 1.0) {
String action = predictions.get(0).name;
Toast.makeText(this, predictions.get(0).name, Toast.LENGTH_SHORT).show();
if ("left".equals(action)) {
Log.i("", "left");
}
else if ("right".equals(action)) {
Log.i("", "right");
}
}
}
을하지만 onGesturePerformed 호출되지 않습니다 : 원래 tutorial에 따라 내 코드를 작성했다.
잘 모르겠지만 스크롤을 허용하기 위해 자체 '제스처'처리 기능을 갖기 때문에 ScrollView를 사용하면 혼란 스럽습니다. LinearLayout으로만 레이아웃을 시험해보고 (ScrollView 제거) 도움이되는지 확인하십시오. – Squonk
@MisterSquonk, ScrollView를 LinearLayout으로 대체하려고 시도했습니다. 도움이되지 않았습니다. –