简体   繁体   English

在framelayout上触摸监听器,在布局夸大时滚动查看

[英]Touch listener on framelayout and scrollview on inflated layout issue

I am doing a flip card application in which i have applied onTouchListener on my frame layout. 我正在做一个翻转卡应用程序,在该应用程序中我在框架布局上应用了onTouchListener。 By using singletap gesturelistener i am flipping card from front to back and vice versa. 通过使用singletap手势侦听器,我可以从前向后翻转卡片,反之亦然。 Every thing is working fine. 一切正常。 As my data is large i have to introduce scroll view on my inflated layouts. 由于我的数据很大,因此我必须在膨胀的布局上引入滚动视图。

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 Layout :- 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>

Frame Layout:- 框架布局:

  <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />

When i am inflating my layout with scroll view, gesture listener is not responding whereas scroll view is working on front card. 当我使用滚动视图放大布局时,手势侦听器没有响应,而滚动视图在前端卡上工作。 I am unnable to flip, if i am using scroll view. 如果我使用滚动视图,则无法翻转。

Please help me, how i can solve this.. 请帮助我,我该如何解决..

You should override the ScrollView's onTouchListener. 您应该重写ScrollView的onTouchListener。 In it you can check whenever to flip your card or scroll... 您可以在其中检查何时翻转卡片或滚动...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM