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

Support Library v23.2 overview

Support Library v23.2 overview

shibuya.apk #6で発表した内容です

Takahiro Shimokawa

March 16, 2016
Tweet

More Decks by Takahiro Shimokawa

Other Decks in Programming

Transcript

  1. About me 4 Zaim Inc. 4 GitHub / Twitter /

    Qiita 4 @androhi 4 DroidKaigi 2016 staff & speaker @androhi 2
  2. DayNight ςʔϚͷ௥Ճ <style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> ... </style> // ΞϓϦશମʹઃఆ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);

    // Activity΍Dialog୯ҐͰઃఆ AppCompatDelegate delegate = getDelegate(); delegate.setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); @androhi 6
  3. ΧελϜλϒͷϘτϜόʔ // VectorDrawableͰ΋େৎ෉ʂ Bitmap icon1 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_room_24dp); Bitmap icon2

    = BitmapFactory.decodeResource(getResources(), R.drawable.ic_favorite_24dp); CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() .setToolbarColor(getResources().getColor(R.color.colorPrimary)) .setSecondaryToolbarColor(getResources().getColor(R.color.colorPrimary)) // ௥ՃͰ͖Δͷ͸4ݸ·ͰɻͦΕҎ্͸IllegalStateException .addToolbarItem(1, icon1, "description1", pendingIntent) .addToolbarItem(2, icon2, "description2", pendingIntent) .build(); customTabsIntent.launchUrl(this, Uri.parse("http://zaim.net")); @androhi 9
  4. activity.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view"

    android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ff0000"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/recycler_view" android:background="#00ff00" android:text="Test"/> </RelativeLayout> @androhi 13
  5. ΋͜͠Μͳ list_item.xml ͩͬͨ Β... <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"

    android:layout_height="match_parent"> <TextView android:id="@+id/list_text" android:layout_width="match_parent" android:layout_height="wrap_content"/> </RelativeLayout> @androhi 17
  6. LayoutManager ͷมߋ ϏϧτΠϯͷ LayoutManager ΛܧঝͤͣɺΧε λϜͷ LayoutManager Λ࢖༻͍ͯ͠Δ৔߹ɺ͜ Ε͸ΦϓτΠϯ API

    ʹͳΓ·͢ɻ setAutoMeasureEnabled(true) Λݺͼग़͠ɺ ϝιουͷ Javadoc ʹৄ͘͠هࡌ͞Ε͍ͯΔͱ ͓Γɺࡉ͔ͳมߋΛՃ͑Δඞཁ͕͋Γ·͢ɻ — Google Developers Japan @androhi 20
  7. LayoutManager#setAutoMeasureEn abled(boolean) ϨΠΞ΢τͷଌఆ( onMeasure )Λɺ RecyclerView ͕ߦ͏( =true )ͷ͔ LayoutManager

    ͕ߦ͏( =false )ͷ͔Λఆٛ͢ Δϝιουɻ -> RecyclerView ͕ଌఆ͢Δ৔߹͸ɺࢠͷཁૉ͔ ΒαΠζΛࣗಈܭࢉ͢Δɻ @androhi 21
  8. v23.1 ͷ LinearLayoutManager // Constructor public LinearLayoutManager(Context context, int orientation,

    boolean reverseLayout) { setOrientation(orientation); setReverseLayout(reverseLayout); } @androhi 22
  9. v23.2 ͷ LinearLayoutManager public LinearLayoutManager(Context context, int orientation, boolean reverseLayout)

    { setOrientation(orientation); setReverseLayout(reverseLayout); setAutoMeasureEnabled(true); } @androhi 23