Pro Yearly is on sale from $80 to $50! »

CoordinatorLayoutのBehaviorを使い倒す

Ad449f3f4e595ade283a30c4f66010be?s=47 HiroYUKI Seto
December 12, 2019

 CoordinatorLayoutのBehaviorを使い倒す

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

Ad449f3f4e595ade283a30c4f66010be?s=128

HiroYUKI Seto

December 12, 2019
Tweet

Transcript

  1. $50ࣨ੉ށ༏೭  $PPSEJOBUPS-BZPVUͷ
 #FIBWJPSΛ
 ࢖͍౗͢

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

    $50ࣨॴଐ w ʮೖࣾͨ͠Βطʹొஃ͢Δ͜ͱʹͳ͍ͬͯͨʯ ࣗݾ঺հ
  3. X © DMM.com ࢖͍౗͢

  4. X © DMM.com ͦͷલʹ
 ࢥ͍ग़͢

  5. X © DMM.com $PPSEJOBUPS-BZPVUΛ༻ҙ͢Δ $PPSEJOBUPS-BZPVUͷࢠ7JFXʹ
 app:layout_behavior ଐੑΛ௥Ճ͢Δ Ҏ্ʂ $PPSEJOBUPS-BZPVU#FIBWJPS

  6. X © DMM.com $PPSEJOBUPS-BZPVU#FIBWJPS

  7. X © DMM.com

  8. X © DMM.com $PPSEJOBUPS-BZPVU#FIBWJPS

  9. X © DMM.com

  10. X © DMM.com $PPSEJOBUPS-BZPVUΛ༻ҙ͢Δ $PPSEJOBUPS-BZPVUͷࢠ7JFXʹ
 app:layout_behavior ଐੑΛ௥Ճ͢Δ Ҏ্ʂ $PPSEJOBUPS-BZPVU#FIBWJPS

  11. X © DMM.com #FIBWJPSͱ͸

  12. X © DMM.com l*OUFSBDUJPOCFIBWJPSQMVHJOGPSDIJMEWJFXTPG$PPSEJOBUPS-BZPVU "#FIBWJPSJNQMFNFOUTPOFPSNPSFJOUFSBDUJPOTUIBUBVTFSDBO UBLFPOBDIJMEWJFX5IFTFJOUFSBDUJPOTNBZJODMVEFESBHT  TXJQFT qJOHT PSBOZPUIFSHFTUVSFTz

    $PPSEJOBUPS-BZPVU#FIBWJPS IUUQTEFWFMPQFSBOESPJEDPNSFGFSFODFBOESPJETVQQPSUEFTJHOXJEHFU$PPSEJOBUPS-BZPVU#FIBWJPS
  13. X © DMM.com w ೚ҙͷ7JFXʹ w Կ͔͕ى͖ͨͱ͖ʹ w ࢦఆͨ͠7JFXʹ w

    Կ͔Λ͢Δ Ͳ͏࢖͏͔ w layout_behavior Λॻ͍ͨViewͰͳͯ͘΋Α͍ w %SBH 4XJQF 'MJOH FUD w ͜͜Λ࣮૷͢Δ w YNMͰBQQlayout_behavior Λॻ͍ͨ7JFX
  14. X © DMM.com ͳͥࠓ

  15. X © DMM.com .%$ʹΑͬͯ
 ࠓ
 #FIBWJPS͕೤͍ʂʂ

  16. X © DMM.com ࡞Δ

  17. X © DMM.com • layoutDependsOn w ೚ҙͷ7JFXͰ͋Δ͔Λฦ͢ • onDependentViewChanged w

    ೚ҙͷ7JFXͷϨΠΞ΢τ͕มΘΔͱݺ͹ΕΔ • onNestedScroll / onNestedFling w ର৅ͷ7JFX͕4DSPMM'MJOH͞ΕΔͱݺ͹ΕΔ େࣄͳϝιου
  18. X © DMM.com αϯϓϧϦϙδτϦ IUUQTHJUIVCDPNIJSPZVLJTFUPCFIBWJPSTBNQMF

  19. X © DMM.com class FabRotationBehavior() : CoordinatorLayout.Behavior<View>() { // xmlͰࢦఆͨ͠ࡍʹݺ͹ΕΔίϯετϥΫλ

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

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

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

    ) { child.rotation += dyConsumed } ࣮૷PO/FTUFE4DSPMM
  23. X © DMM.com Ͳ͏࢖͏

  24. X © DMM.com w ೚ҙͷ7JFXʹ w layout_behavior Λॻ͍ͨViewͰͳͯ͘΋Α͍ w Կ͔͕ى͖ͨͱ͖ʹ

    w %SBH 4XJQF 'MJOH FUD w ࢦఆͨ͠7JFXʹ w YNMͰBQQlayout_behavior Λॻ͍ͨ7JFX w Կ͔Λ͢Δ w ͜͜Λ࣮૷͢Δ Ͳ͏࢖͏͔
  25. 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ͷ࢖͍Ͳ͜Ζ
  26. X © DMM.com w ਌͕$PPSEJOBUPS-BZPVUͰͳ͍৔߹ w Ξχϝʔγϣϯ͕7JFXʹ࣮૷͞Ε͍ͯͳ͍ w Ҡಈ΍มܗ͕͋Δ৔߹͸
 #FIBWJPSͰ࣮૷͢ΔΑΓ΋5SBOTJUJPOָ͕

    w 5SBOTJUJPOͱ࣮ͯ͠૷ࡁ͞Ε͍ͯΔ w Ҡಈɺมܗɺग़ݱɺফࣦ 5SBOTJUJPOͷํ͕Α͍ͱ͜Ζ
  27. X © DMM.com ࢖͍Ͳ͜ΖΛ஌ͬͯ ྑ͍#FIBWJPSϥΠϑΛ

  28. X © DMM.com w ެࣜϦϑΝϨϯε w IUUQTEFWFMPQFSBOESPJEDPNSFGFSFODFBOESPJETVQQPSUEFTJHOXJEHFU $PPSEJOBUPS-BZPVU#FIBWJPS w NBUFSJBMDPNQPOFOUTBOESPJE

    w IUUQTHJUIVCDPNNBUFSJBMDPNQPOFOUTNBUFSJBMDPNQPOFOUTBOESPJEUSFF NBTUFSMJCKBWBDPNHPPHMFBOESPJENBUFSJBMUSBOTGPSNBUJPO ࢀߟจݙ
  29. X © DMM.com w %SPJE,BJHJ
 .%$ͷ಺෦࣮૷͔ΒֶͿදݱྗͷߴ͍7JFXͷ࡞Γํ ΦϋφγϋπρΫ

  30. ׬