【发布时间】:2014-12-07 04:20:16
【问题描述】:
我的线性布局:main_linear_layout 包含四个线性布局:ll1ll2ll3ll4。每个LinearLayout 都包含Buttons。我正在尝试在main_linear_layout 上实现 onFling 方法。我希望能够在Buttons 的布局上任意滑动并调用操作。
目前我可以在屏幕上的任何地方滑动,除了按钮的布局。我尝试使用以下代码来解决问题:
swipeLayout = (LinearLayout) findViewById(R.id.main_linear_layout);
//swipeLayout is the main Layout that contains 4 other linear layouts
swipeLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
gestureScanner.onTouchEvent(event);
return true;
}
});
但我仍然无法在Buttons 的布局上滑动。有谁知道这是为什么?还有什么我需要实施的吗?我是否应该为主线性布局内的每个线性布局实现OnTouchListener?或者每个布局中的每个Button?
并且在xml 中,我在主线性布局中添加了一堆代码:
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:longClickable="true"
但这也不起作用。有人可以帮忙吗?
【问题讨论】:
标签: java android android-linearlayout onfling