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

CoordinatorLayoutのBehaviorを使い倒す

HiroYUKI Seto
December 12, 2019

 CoordinatorLayoutのBehaviorを使い倒す

19/12/12
DMM Android勉強会 #3

HiroYUKI Seto

December 12, 2019
Tweet

More Decks by HiroYUKI Seto

Other Decks in Technology

Transcript

  1. X © DMM.com w ੉ށ༏೭ w !TFUP@IJ w ೥݄ೖࣾ w

    $50ࣨॴଐ w ʮೖࣾͨ͠Βطʹొஃ͢Δ͜ͱʹͳ͍ͬͯͨʯ ࣗݾ঺հ
  2. X © DMM.com w ೚ҙͷ7JFXʹ w Կ͔͕ى͖ͨͱ͖ʹ w ࢦఆͨ͠7JFXʹ w

    Կ͔Λ͢Δ Ͳ͏࢖͏͔ w layout_behavior Λॻ͍ͨViewͰͳͯ͘΋Α͍ w %SBH 4XJQF 'MJOH FUD w ͜͜Λ࣮૷͢Δ w YNMͰBQQlayout_behavior Λॻ͍ͨ7JFX
  3. X © DMM.com • layoutDependsOn w ೚ҙͷ7JFXͰ͋Δ͔Λฦ͢ • onDependentViewChanged w

    ೚ҙͷ7JFXͷϨΠΞ΢τ͕มΘΔͱݺ͹ΕΔ • onNestedScroll / onNestedFling w ର৅ͷ7JFX͕4DSPMM'MJOH͞ΕΔͱݺ͹ΕΔ େࣄͳϝιου
  4. X © DMM.com class FabRotationBehavior() : CoordinatorLayout.Behavior<View>() { // xmlͰࢦఆͨ͠ࡍʹݺ͹ΕΔίϯετϥΫλ

    constructor( context: Context, attrs: AttributeSet ) : this() } ࣮૷ίϯετϥΫλ
  5. X © DMM.com override fun layoutDependsOn( … ): Boolean {

    return dependency is NestedScrollingChild2 } ࣮૷PO4UBSU/FTUFE4DSPMM
  6. X © DMM.com override fun onStartNestedScroll( … ): Boolean {

    //trueΛฦ͢ͱ onNestedScroll ͕ݺ͹ΕΔ return true } ࣮૷PO4UBSU/FTUFE4DSPMM
  7. X © DMM.com override fun onNestedScroll( … dyConsumed: Int …

    ) { child.rotation += dyConsumed } ࣮૷PO/FTUFE4DSPMM
  8. X © DMM.com w ೚ҙͷ7JFXʹ w layout_behavior Λॻ͍ͨViewͰͳͯ͘΋Α͍ w Կ͔͕ى͖ͨͱ͖ʹ

    w %SBH 4XJQF 'MJOH FUD w ࢦఆͨ͠7JFXʹ w YNMͰBQQlayout_behavior Λॻ͍ͨ7JFX w Կ͔Λ͢Δ w ͜͜Λ࣮૷͢Δ Ͳ͏࢖͏͔
  9. X © DMM.com w ਌͕$PPSEJOBUPS-BZPVU ඞਢ  w 7JFXͷϝιουΛୟ͚ͩ͘ w

    FYWJFXͷSPUBUJPOΛม͑Δ WJTJCJMJUZΛม͑Δ w FY&YUFOEFE'MPBUJOH"DUJPO#VUUPOFYUFOE TISJOL  w Ҡಈ΍มܗ͕ͳ͍Ξχϝʔγϣϯ w FY৭ͷมԽɺճసɺ⾩Ͱͳ͍ΞϧϑΝ஋ w 5SBOTGPSNͷྫ͸ʜ #FIBWJPSͷ࢖͍Ͳ͜Ζ
  10. X © DMM.com w ެࣜϦϑΝϨϯε w IUUQTEFWFMPQFSBOESPJEDPNSFGFSFODFBOESPJETVQQPSUEFTJHOXJEHFU $PPSEJOBUPS-BZPVU#FIBWJPS w NBUFSJBMDPNQPOFOUTBOESPJE

    w IUUQTHJUIVCDPNNBUFSJBMDPNQPOFOUTNBUFSJBMDPNQPOFOUTBOESPJEUSFF NBTUFSMJCKBWBDPNHPPHMFBOESPJENBUFSJBMUSBOTGPSNBUJPO ࢀߟจݙ
  11. ׬