• 请不要在回答技术问题时复制粘贴 AI 生成的内容
airqj
V2EX  ›  程序员

android 如何实现长图在 view 里自动滚动?

  •  
  •   airqj · Oct 20, 2017 · 4164 views
    This topic created in 3314 days ago, the information mentioned may be changed or developed.

    目前业余时间在写一个应用,要显示一张长图片,在不需要手指滑动的情况下让图片自动滚动
    尝试了 BigImageView 之类的库,没找到相应的功能
    原本是打算模拟手指触屏事件来实现,但是发现 android 下面并没有相应的 API
    熟悉 android 开发的兄弟们可否给个思路?

    9 replies  •  2017-10-21 10:34:48 +08:00
    srx1982
    srx1982
    Oct 20, 2017❤️1
    1
    用 canvas 来画
    airqj
    airqj
    OP
    Oct 20, 2017
    2
    @srx1982 多谢兄弟 我试一下
    twoyuan
    twoyuan
    Oct 20, 2017
    3
    一楼大佬……我觉得放到 ScrollView 里然后调用滚动方法最简单吧
    airqj
    airqj
    OP
    Oct 20, 2017
    4
    @twoyuan 没试过 scrollView
    BigImageView.scrollBy 的时候是 VIew 在动 而不是图片在动....
    twoyuan
    twoyuan
    Oct 20, 2017
    5
    scrollView.scrollTo(0, yPos)
    srx1982
    srx1982
    Oct 20, 2017
    6
    @twoyuan 好像是这样的哈哈哈
    Cabana
    Cabana
    Oct 20, 2017 via Android
    7
    自己在 canvas 里 draw bitmap 然后不断位移比放 scroll view 里简单些,可控性还高些。
    airqj
    airqj
    OP
    Oct 21, 2017
    8
    @srx1982
    @twoyuan
    @Cabana
    多谢三位 我试一下
    srx1982
    srx1982
    Oct 21, 2017
    9
    @airqj 两种方式都试试吧,多学点挺好
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   917 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 21:19 · PVG 05:19 · LAX 13:19 · JFK 16:19
    ♥ Do have faith in what you're doing.