繁体   English   中英

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

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

我正在做一个翻转卡应用程序,在该应用程序中我在框架布局上应用了onTouchListener。 通过使用singletap手势侦听器,我可以从前向后翻转卡片,反之亦然。 一切正常。 由于我的数据很大,因此我必须在膨胀的布局上引入滚动视图。

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" />

当我使用滚动视图放大布局时,手势侦听器没有响应,而滚动视图在前端卡上工作。 如果我使用滚动视图,则无法翻转。

请帮助我,我该如何解决..

您应该重写ScrollView的onTouchListener。 您可以在其中检查何时翻转卡片或滚动...

暂无
暂无

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

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