gpt4 book ai didi

java - 如何使 "swipe up"功能像许多自定义启动器一样?

转载 作者:行者123 更新时间:2023-12-02 05:38:05 27 4
gpt4 key购买 nike

我目前正在为 Android 制作自己的自定义启动器。到目前为止一切正常。但有一点我需要帮助。我想做一些事情,比如在主屏幕上向上滑动以显示所有已安装的应用程序。因此我不想开始新的 Activity ,导致延迟。也许可以在检测到手势时使用动画之类的东西来更改布局文件?我如何检测滑动?

最佳答案

检测运动真的很容易:

someViewLikeLinearLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
//put finger on screen
return true;
case MotionEvent.ACTION_UP:
//release the finger
return true;

}

}
});

只需切换事件,您就可以通过MotionEvent获得许多 Action 祝你好运!

关于java - 如何使 "swipe up"功能像许多自定义启动器一样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56154580/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com