Android 触摸framelayout上的listener并滚动查看膨胀的布局问题
我正在做一个翻转卡应用程序,我已经在我的框架布局上应用了onTouchListener。通过使用singletap手势监听器,我将卡片从前到后翻转,反之亦然。一切正常。由于我的数据量很大,我不得不在我膨胀的布局上引入滚动视图Android 触摸framelayout上的listener并滚动查看膨胀的布局问题,android,scrollview,ontouchlistener,android-framelayout,gestures,Android,Scrollview,Ontouchlistener,Android Framelayout,Gestures,我正在做一个翻转卡应用程序,我已经在我的框架布局上应用了onTouchListener。通过使用singletap手势监听器,我将卡片从前到后翻转,反之亦然。一切正常。由于我的数据量很大,我不得不在我膨胀的布局上引入滚动视图 setContentView(R.layout.flashframe); cardView = (FrameLayout)findViewById(R.id.container); cardView.setOnTouchListener(this); mGe
setContentView(R.layout.flashframe);
cardView = (FrameLayout)findViewById(R.id.container);
cardView.setOnTouchListener(this);
mGestureDetector=new GestureDetector(this.getBaseContext(), new MyGestureListener(this));
if(savedInstanceState==null){
getFragmentManager().beginTransaction()
.add(R.id.container, new CardFrontFragment()).commit();
cardNumber=1;
setCard(cardNumber);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
mGestureDetector.onTouchEvent(event);
return true;
}
public class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
public MyGestureListener(OpenClass openClass) {
// TODO Auto-generated constructor stub
}
@Override
public boolean onSingleTapUp(MotionEvent me)
{
flipCard();
return true;
}
}
XML布局:-
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:weightSum="100" android:layout_height="match_parent">
<ScrollView android:layout_weight="30" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="To be retrieved from sqlite"
android:layout_width="match_parent" android:layout_height="match_parent"></TextView>
</ScrollView>
</LinearLayout>
框架布局:-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
当我使用scroll view扩展布局时,手势侦听器没有响应,而scroll view正在前卡上工作。如果使用滚动视图,则无法翻转
请帮助我,我如何解决这个问题。您应该覆盖ScrollView的onTouchListener。在其中,您可以随时检查是否翻转卡或滚动…发布布局xml@ChadiAbou Sleiman--我已经发布了我的xml布局。您的框架布局在哪里???@Chadi Abou Sleiman--发布了哪一个是完整的
R.layout.flashframe
xml?下面是一个示例: