Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RecyclerViewでViewPagerっぽいの作ろうとして頓死した話

 RecyclerViewでViewPagerっぽいの作ろうとして頓死した話

bigbackboom

March 19, 2019
Tweet

More Decks by bigbackboom

Other Decks in Technology

Transcript

  1. RecyclerViewͰ
    ViewPagerͬΆ͍ͷ࡞
    Ζ͏ͱͯ͠಴ࢮͨ͠࿩

    View full-size slide

  2. ࣗݾ঺հ
    • ໊લɿ٠஑/bigbackboom
    • ʢͳΜͪΌͬͯʣAndroid։ൃऀ
    • ॴଐɿגࣜձࣾΞΠελΠϧ -> CBCloudגࣜձࣾ
    • גࣜձࣾΞΠελΠϧͰ͸αʔόʔαΠυ(golang)ͷ։ൃ΋݉೚
    • ໨ࢦͤʲ;Δͨͬ͘͢ʳ

    View full-size slide

  3. ViewPagerͱ͸ʁ
    • λϒͷ͋Δը໘ͷ࡞੒
    • λϒλοϓͰͷը໘ભҠ͕Մೳ
    • εϫΠϓͰͷը໘ͷભҠ͕Մೳ
    • ॳظબ୒ͷը໘ͱࠨӈͷը໘Λ͋Β͔
    ͡ΊॳظԽ͕Մೳ

    View full-size slide

  4. ଞʹ΋ʁ
    • ΧϧʔηϧͳΜ͔΋࡞ΕΔ
    • ϫϯεϫΠϓͰҰݸͣͭҠಈ͢ΔΧʔ
    υ
    • ࠨӈʹνϥݟͷΧʔυΛ഑ஔ͢Δ͜ͱ
    ΋Մೳ

    View full-size slide

  5. ͳͥRecyclerViewͰ࡞Δͷʁ
    • ViewPagerͰΧϧʔηϧ࡞Ζ͏ͱͨ͠Β͸Ұ౓ը໘֎ʹΧʔυΛ
    ग़͞ͳ͍ͱɺߋ৽͕ը໘ʹදࣔ͞Εͳ͍঱ঢ়͕ग़ͨɻ
    • ΧϧʔηϧͷΧʔυ࡟আ΋ɺը໘֎ʹग़͢ඞཁ͕͋Δɻ

    View full-size slide

  6. ͜ΜͳΧϧʔηϧΛ࡞ͬͨͱ͖

    View full-size slide

  7. σʔλ͕มߋ͞Εͯ΋ɾɾɾ

    View full-size slide

  8. Ұ౓ը໘֎΁

    View full-size slide

  9. Α͏΍͘಺༰͕มΘΔ

    View full-size slide

  10. ࡟আͷ৔߹΋

    View full-size slide

  11. 3Λ࡟আʂ൓ө͞Εͣ...

    View full-size slide

  12. Ұ౓ը໘֎ʹग़ͯ͠

    View full-size slide

  13. ࡟আ͕൓ө

    View full-size slide

  14. Ͱ΋RecyclerViewͳΒ
    • ߋ৽͕ଈ࣌൓ө
    • Ϧιʔεͷ࢖༻΋গͳΊ

    View full-size slide

  15. ํ਑
    • ϫϯεϫΠϓͰɺΧʔυ͕Ұݸಈ͘εϫΠϓΛ࣮ݱ
    • ແݶͷεΫϩʔϧΛ࣮ݱ͢Δ

    View full-size slide

  16. Χʔυ͕Ұݸಈ͘εϫΠϓΛ࣮ݱ
    • PagerSnapΛRecyclerViewʹ౉͚ͩ͢ͰOK
    val helper = PagerSnapHelper()
    helper.attachToRecyclerView(this)

    View full-size slide

  17. ແݶͷεΫϩʔϧΛ࣮ݱ͢Δ
    • ͪ͜ΒΛࢀߟʹ͠·ͨ͠
    • ϦετΛ3ηοτ༻ҙͯ͠ɺ̎ηοτ໨ʹ͋Β͔͡ΊҐஔΛઃఆ
    ͢Δ
    • εϫΠϓͰ̎ηοτ໨͔Β֎ΕΑ͏ͱͨ͠Βɺ2ηοτ໨ͷ͍ͣ
    Ε͔ͷ৔ॴʹڧ੍εΫϩʔϧͤ͞Δɻ

    View full-size slide

  18. why?
    • ॳظҐஔΛ͏·͍͜ͱઃఆͰ͖ͣɺ
    Χʔυ͕ਅΜதʹͳΒͳ͍ࣄ৅͕ଟൃ
    ͢Δ
    • εϫΠϓ͢ΔͱมͳҐஔʹͳΔ໰୊

    View full-size slide

  19. େࣦഊ
    • ݁Ռతʹ࣌ؒͳ͍ʹͰ͖ͦ͏ʹͳ͍ͷͰɺ͜ͷ࣌͸طଘ࣮૷Λ
    ར༻͢Δܗʹ͠·ͨ͠ɻ
    • ײ૝ɿ
    • ΍ͬͪ·ͬͨͳ͊
    • ViewPager࢖͏࣌͸اըͱͷ࢓༷֬ೝΛগ͠ࡉ͔͘٧ΊΔΑ
    ͏ʹ͠Α͏ͱࢥͬͨɻ
    • https:/
    /github.com/BigBackBoom/LoopingPagerSnapViewer

    View full-size slide