我有三个标签的tabactivity.其中一个选项卡包含ListActivity,另外两个包含简单的Activity.我已经实现了OnGestureListener来更改fling事件的选项卡.
使用onTouchEventListActivity的选项卡不会调用和'onFling'事件.但是对于Simple Activity(没有列表)工作正常.
这是我的代码:
主要活动类:
public class GestureTest extends TabActivity implements OnGestureListener {
private TabHost tabHost;
private GestureDetector gestureScanner;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testmainlayoutforgesture);
gestureScanner = new GestureDetector(this);
addTabs();
}
private void addTabs() {
Intent i1 = new Intent().setClass(this, SimpleListActivity.class);
Intent i2 = new Intent().setClass(this, SimpleActivity.class);
Intent i3 = new Intent().setClass(this, SimpleActivity.class);
tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("First").setIndicator("First").setContent(i1));
tabHost.addTab(tabHost.newTabSpec("Second").setIndicator("Second").setContent(i2));
tabHost.addTab(tabHost.newTabSpec("Third").setIndicator("Third").setContent(i3));
tabHost.setCurrentTab(0);
}
@Override
public boolean onTouchEvent(MotionEvent me) {
return gestureScanner.onTouchEvent(me);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent …Run Code Online (Sandbox Code Playgroud) 我查看了其他解决方案,但我找不到适合自己的解决方案.我有一个,我UIImageView在UIScrollView那里展示大图.
我在我的UIScrollView以及左右滑动手势识别器中启用了捏合手势.
现在,scrollview的平移手势似乎禁用,(或损坏)滑动手势.我不想禁用水平或垂直滚动UIScrollView,我的照片的初始缩放太大,无法禁用水平滚动.
我想要做的是当我来到UIScrollView的边缘时触发滑动手势.
这是一些代码;
- (void)viewDidLoad
{
// recognizer for pinch gestures
UIPinchGestureRecognizer *pinchRecognizer =[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(handlePinch:)];
[self.myScrollView addGestureRecognizer:pinchRecognizer];
[self.myScrollView setClipsToBounds:NO];
// recognizer for swipe gestures
UISwipeGestureRecognizer *recognizer;
// left and right swipe recognizers for left and right animation
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleLeftSwipe:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[[self myScrollView] addGestureRecognizer:recognizer];
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleRightSwipe:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[[self myScrollView] addGestureRecognizer:recognizer];
....
Run Code Online (Sandbox Code Playgroud)
我的左侧滑动处理程序,目前左右滑动没有任何其他功能
-(void)handleLeftSwipe:(UISwipeGestureRecognizer *)recognizer
{
if(!self.tableView.hidden) self.tableView.hidden = YES;
[self …Run Code Online (Sandbox Code Playgroud) 我有一个用例,屏幕上有两个视图,其中一个部分覆盖另一个.上面的那个需要处理滚动事件并忽略修饰.部分模糊的视图应该处理触摸事件,包括在模糊视图忽略的重叠区域中发生的事件.
下面是一个简化的示例布局.

我最接近的是在顶视图上使用GestureDetectorCompat在onDown中返回true(否则我没有得到任何进一步的事件),在onScroll中返回true,在onSingleTapUp中返回false.我在后面的视图中尝试了几个具有相同结果的东西:我在未模糊的部分上轻拍,但顶视图吃掉了模糊部分的所有运动事件.
我想结合默认的VideoView和手势侦听器,
如果用户向左滑动则歌曲向后播放或向右滑动则歌曲向前播放,我想在 VideoView 上实现同样的方法。
通过以下代码打开默认媒体播放器:
Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
那么如何添加手势监听器..?
但问题是它只是在图像视图边界内移动和缩放。我想要的是用两个手指手势调整图像视图的大小。它应该根据收缩变大或变小。我整天都在谷歌上搜索调整大小,但无法弄清楚。所有的教程只指出我在 ImageView 内部缩放而不是调整大小。以下是我从博客中生成的自定义图像视图代码。
public class InteractableImageView extends ImageView implements View.OnTouchListener {
private static final int INVALID_POINTER_ID = -1;
private ScaleGestureDetector mScaleDetector;
private float mScaleFactor = 1.f;
private int mActivePointerId = INVALID_POINTER_ID;
private float mPosX;
private float mPosY;
private float mLastTouchX;
private float mLastTouchY;
public InteractableImageView(Context context) {
this(context, null, 0);
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
}
public InteractableImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
}
public …Run Code Online (Sandbox Code Playgroud) 我想实现与开发人员选项的 android 设置应用程序类似的行为。我的意思是当用户连续点击按钮 7 次并且每次点击之间有一个小的延迟时,会出现一个弹出窗口,要求他启用应用程序中的隐藏功能。
我该如何实现这种行为?
我已经看到,自最新更新(Windows Fall Creators Update)以来,存在一组 Swipe Classes,但在 VS(15.4.1)的当前稳定版本中,没有办法让它工作。我目前正在使用 Visual Studio 2017 Enterprise ( 15.4.1 ) 运行最新的 W10 更新 (1709),但无法使其正常工作。我试图使以下示例工作但没有运气:https : //channel9.msdn.com/Events/Windows/Windows-Developer-Day-Fall-Creators-Update/WinDev015#comments
在Xamarin.Forms中,在iOS上,如何扩展TabbedPage以便除了使用底部的选项卡更改页面外,用户还可以向左或向右滑动以更改页面?理想情况下,刷卡时应该动画页面过渡.
所有页面都不在页面内使用左手势或右手势,因此可以向左或向右滑动以明确指示更改当前页面的愿望.
我想在 iOS Swift 4.* 中使用 UILongPressGestureRecognizer 方法传递一些参数。
let buttonLongGesture = UILongPressGestureRecognizer(target: self, action: #selector(buttonPressedLong(_:)))
button.addGestureRecognizer(buttonLongGesture)
@objc func buttonPressedLong(_ sender:UIGestureRecognizer) {
}
Run Code Online (Sandbox Code Playgroud) 我正在为我当前的项目使用 React-Navigation 库,但不喜欢向后滑动功能。只有当您将手指放在屏幕的整个边缘以便手势向后滑动时,它才会被触发。我已经阅读了API 参考,但找不到任何关于我的行为问题的信息。
gesture ×10
android ×5
ios ×2
swipe ×2
animation ×1
audio-player ×1
c# ×1
imageview ×1
iphone ×1
listactivity ×1
react-native ×1
scroll ×1
swift ×1
tabactivity ×1
tabbedpage ×1
target ×1
uiscrollview ×1
uwp ×1