BottomBarAndSnackBar

8928b5277aa7234dbca4ff782952343a?s=47 funnelbit
December 26, 2016

 BottomBarAndSnackBar

8928b5277aa7234dbca4ff782952343a?s=128

funnelbit

December 26, 2016
Tweet

Transcript

  1. #PUUPN#BS ͱ 4OBDL#BS

  2. ࣗݾ঺հ ๺ଜྋ גࣜձࣾ͸ͯͳ )BUFOBGVOOFMCJU 5XJUUFS!FYQFSPQFSP

  3. %SPJE,BJHJͰൃද͠·͢ w λΠτϧʮେن໛ΞϓϦͷϦϊϕʔγϣϯʯ w ͓ٓ͘͠ئ͍͠·͢"

  4. 4OBDL#BSͱ#PUUPN#BS ͷ૊Έ߹Θͤʹ͍ͭͯ

  5. "DUJWJUZ 'SBHNFOU Ͱ'SBHNFOU͔Β 4OBDL#BSΛͩ͢

  6. "DUJWJUZ 'SBHNFOU  4OBDL#BS

  7. "DUJWJUZ 'SBHNFOU  4OBDL#BS Snackbar.make(v, "SnackBar!!", Snackbar.LENGTH_LONG).show(); w 'SBHNFOUͰݺͿ

  8. None
  9. "DUJWJUZ #PUUPN#BS   'SBHNFOUͰ'SBHNFOU͔ Β4OBDL#BSΛͩ͢

  10. "DUJWJUZ #PUUPN#BS   'SBHNFOU 4OBDL#BS

  11. None
  12. "DUJWJUZ #PUUPN#BS   'SBHNFOU 4OBDL#BS w 4OBDL#BS͸දࣔ͢Δ࣌ɺ਌7JFXΛḷͬͯద ੾ͳ਌7JFX(SPVQ಺ʹදࣔ͞ΕΔ

  13. "DUJWJUZ #PUUPN#BS   'SBHNFOU 4OBDL#BS w 3FMBUJWF-BZPVU w "QQCBS

    w $PPSEJOBUPS-BZPVU w 'SBHNFOU w $PPSEJOBUPS-BZPVU w 5PPMCBS w 3FMBUJWF-BZPVU w "DUJWJUZͷϨΠΞ΢τΛॻ͖׵͑Δ
  14. None
  15. "DUJWJUZ ಈ͘"QQ#BSͱ #PUUPN#BS  'SBHNFOUͰ 'SBHNFOU͔Β4OBDL#BSΛͩ͢

  16. None
  17. "DUJWJUZͷ#FIBWJPSͰͳΜ ͱ͔͢Δʁ if (dependency instanceof Snackbar.SnackbarLayout) {
 int targetPadding =

    Math.max(0, bottomBar.getMeasuredHeight() - (int) (bottomBar.getY() - bottomBar.getTop()));
 dependency.setPadding(dependency.getPaddingLeft(), dependency.getPaddingTop(), dependency.getPaddingRight(), targetPadding);
 } w #PUUPN#BSͷ#FIBWJPSͱͯ͜͠ΜͳͷΛॻ͘
  18. None
  19. w 4OBL#BSʹ͸&MFWBUJPO͕͋Δ EQ  w IUUQTNBUFSJBMJPHVJEFMJOFTDPNQPOFOUT CPUUPNOBWJHBUJPOIUNMCPUUPNOBWJHBUJPO TQFDT

  20. <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 app:layout_behavior="com.example.funnelbit.snackbarapp.BottomBarB ehavior"
 android:layout_gravity="bottom"
 android:elevation="8dp"

  21. ݹ͍όʔδϣϯΛߟྀ // ΋͠΋ KITKAT ҎԼͰ͋Δ৔߹ɺelevation ͕࢖͑ͳ͍ͨΊɺbottomBar ͷ্ʹ Snackbar ͕ඃͬͯ͞͠·͏ɻ
 //

    ͦ͜Ͱ bringToFront() Λ࢖͍ɺॏͶॱΛม͑Δɻ
 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
 bottomBar.bringToFront();
 // KITKAT ΑΓલͷόʔδϣϯͷ৔߹ɺrequestLayout() ͱ invalidate() Λݺ͹ͳ͚Ε͹ ॏͶॱͷมߋ͕ͳ͞Εͳ͍ɻ
 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
 bottomBar.getParent().requestLayout();
 ((View) bottomBar.getParent()).invalidate();
 }
 }
 return true; w #PUUPN#BSͷ#FIBWJPSͱͯ͜͠ΜͳͷΛॻ͘ʢଓ͖ʣ
  22. None
  23. None
  24. w ௒଎Ͱಈ͔͢ͱͪΐͬͱ͓͔͘͠ͳΔ

  25. *OUFSGBDF public interface ErrorMessageInterface {
 void show(String text);
 }

  26. 'SBHNFOU ((ErrorMessageInterface) getActivity()).show("SnackBar!!");

  27. "DUJWJUZ Snackbar.make(findViewById(R.id.snackbar_container), "SnackBar!!", Snackbar.LENGTH_LONG).show();

  28. -BZPVU "DUJWJUZ w $PPSEJOBUPS-BZPVU w "QQ#BS w 'SBHNFOU w #PUUPN#BS$POUBJOFS

    w $PPSEJOBUPS-BZPVU w #PUUPN#BS$POUFOU w $PPSEJOBUPS-BZPVU
  29. None
  30. ·ͱΊ w ৭ʑํ๏͕͋Γͦ͏͕ͩʜ w ݁ہ"DUJWJUZʹΤϥʔදࣔΛ೚ͤΔͷ͕Α͍ w 'SBHNFOU͸਌͕Կͳͷ͔஌Δ༝΋ͳ͍ͷͰ w ࡦ͕͋Ε͹ڭ͍͑ͯͩ͘͞

  31. ͋Γ͕ͱ͏͍͟͝·ͨ͠