GridView动画水平滑动

编程入门 行业动态 更新时间:2024-10-27 01:20:31
本文介绍了GridView动画水平滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

出于某种原因,我必须创建一个自定义日历组件,其中包含针对日期的自定义视图-用于不同类型日期的不同视图-正常,事件等-从JSON加载年份配置等.

For one reason or another, I had to create a custom calendar component with custom views for days - different views for different types of dates - normal, events, etc - loading year configuration from JSON, etc.

  • 我通过使用适配器扩展GridView来创建它.
  • 我已经创建了JSON配置加载等.
  • 我已经使用网格触摸事件来简化当月的更改.
  • 但是我需要以滑动"左右动画的方式进行操作-就像在Android日历应用程序中一样.

    But I need to do this "sliding" left and right animated - as it is in the android calendar application.

    例如.我已经在网络上阅读了很多东西,但是仍然找不到有关如何使用GridView进行操作的提示.

    for example. I've read a lot on the web, but I still cannot find any tips on how to do this with GridView.

    使用GridView作为基类也许不是最好的主意. 任何帮助将不胜感激.

    Maybe it was not the best idea to use GridView as a base class. Any help would be appreciated.

    推荐答案

    我使用了以下变体:

    • 已加载3页(0、1、2)的ViewPager.
    • 在每个页面上,我都有一个GridView代表日历中的一个月.

    第0页是上个月 在第1页是当前月份 在第2页是下个月

    On page 0 is the previous month On page 1 is the current month On page 2 is the next month

    在ViewPager适配器中,我将适配器用于3个Gridview.

    In ViewPager adapter I used adapters for the 3 Gridviews.

    最初,我将活动页面设置为1.

    Initially I set active page to 1.

    每次更改页面时,我都会重新计算上个月,当前月份和下个月的月份数据,然后将活动页面再次设置为1.

    On each page change I recalculate the month data for previous, current and next month and set active page again to 1.

    这样,我可以模拟类似无限"视图寻呼机的内容. 目前,我的任务没问题-滑动页面日历.

    This way I simulate something like "infinite" view pager. For the moment it's ok for my task - sliding pages calendar.

    更多推荐

    GridView动画水平滑动

    本文发布于:2023-11-27 20:51:46,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1639559.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:水平   动画   GridView

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!