Android 的 Horizo​​ntalScrollView 菜单

发布于 2024-09-25 06:08:21 字数 510 浏览 0 评论 0原文

我有一个由 Horizo​​ntalScrollView 组成的菜单,该 View 具有带有 TextView 的 LinearLayout。当用户滑动/滚动时,我希望能够显示和不显示表示有更多选项的前导和尾随图像。因此,当应用程序启动时,不会显示最左侧的图像,而是显示最右侧的图像。一旦用户向右滑动,就会显示最左侧的图像。当您到达右侧最后一个选项时,正确的图像就消失了。

我尝试使用 SimpleOnGestureListener 但似乎报告的位置是用户所在的位置而不是列表的位置。我想我可以做这样的事情:

if(scrollX < 200.0) { tempL.setVisibility(View.INVISIBLE); } else tempL.setVisibility(View.VISIBLE);

我什至实现了 onFling 和 onScroll 方法来尝试,但没有得到预期的结果。此外,仅当用户再次滚动时才会报告该位置。因此,猛击位置可能是 1278,并一直到 0,但直到用户尝试再次猛击时才会报告 0。

谢谢。

I have a menu that is made up of a HorizontalScrollView that has a LinearLayout with TextViews. When a user swipes/scrolls I want to be able to show and not show a leading and trailing image that represents that there are more options. So, when the application starts, the far left image is not shown but the far right image is. Once the user swipes to go right, the far left image is shown. When you get to the very last option to the right, the right image is gone.

I have tried to use the SimpleOnGestureListener but it seems that the position reported is where the user is instead of the position of the list. I was thinking I could just do something like:

if(scrollX < 200.0) {
tempL.setVisibility(View.INVISIBLE);
} else tempL.setVisibility(View.VISIBLE);

I even implemented both onFling and onScroll methods to try but did not get the expected results. Also, the position is only reported when the user scrolls again. So, a fling position may be 1278 and go all the way to 0 but 0 is not reported until the user tries to fling again.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

数理化全能战士 2024-10-02 06:08:21

您可以为此使用图库。虽然它有一些限制,但我想它比水平滚动视图更能满足您的要求。

You can use gallery for this. It has some limitations though, but I guess it would suit your requirement better than a horizontal Scroll View.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文