Elevationで影が思ったように出ないとき

6139fd48daa26e786794598c4a6b546a?s=47 ninjinkun
January 15, 2015

 Elevationで影が思ったように出ないとき

Android 5.0のelevationのバッドノウハウ集です

6139fd48daa26e786794598c4a6b546a?s=128

ninjinkun

January 15, 2015
Tweet

Transcript

  1. &MFWBUJPOͰӨ͕
 ࢥͬͨΑ͏ʹग़ͳ͍ͱ͖ OJOKJOLVO

  2. &MFWBUJPOͱ͸ w "OESPJE͔Βಋೖ͞Εͨ
 7JFXͷߴ౓ͷ֓೦ w ઃఆ͢Δͱ7JFXʹӨ͕ண͘ w Ϣʔβʔ͕֤7JFXͷॏͳΓ߹͍ Λ஌Δख͕͔ΓʹͳΔ w

    ҎલͰ͸ݟ͑ͳ͍ͷͰઃఆͯ͠΋ແҙ
  3. Ө͕ࢥͬͨΑ͏ʹ
 ग़ͳ͍

  4. ͳΜ͔Ө͕ग़ͳ͍ w 7JFXͷ·ΘΓʹ༨ന͕ඞཁ ੾ΕͯΔ NBSHJO͋Γ

  5. ͳΜ͔Ө͕ग़ͳ͍ w 7JFXͷ·ΘΓʹ༨ന͕ඞཁ ੾ΕͯΔ NBSHJO͋Γ

  6. ͳΜ͔Ө͕ग़ͳ͍ w CBDLHSPVOEʹΞϧϑΝ஋͕ઃఆ͞Ε͍ͯΔͱӨ͕ ग़ͳ͍ w όάͰ͸ͳ͍͔ͱݴΘΕ͍ͯΔ IUUQTUBDLPWFSqPXDPNRVFTUJPOTFMFWBUJPOPOBOESPJEMPMMJQPQOPUXPSLJOH

  7. ͳΜ͔Ө͕ग़ͳ͍ w #VUUPOʹFMFWBUJPO͕౰ͨΒͳ͍ w TUBUF-JTU"OJNBUPS͕FMFWBUJPOΛ্ॻ͖ͯ͠Δ w σϑΥϧτͩͱ#VUUPO͸EQු͍ͯΔ IUUQRJJUBDPN(FTZVUBQPJUFNTGGCGFF <item android:state_enabled="true">

    <set> <objectAnimator android:propertyName="translationZ" android:duration="@integer/button_pressed_animation_duration" android:valueTo="0" android:startDelay="@integer/button_pressed_animation_delay" android:valueType="floatType"/> <objectAnimator android:propertyName="elevation" android:duration="0" android:valueTo="@dimen/button_elevation_material" android:valueType="floatType" /> </set> </item> ͓લ͔ʂ TUBUF-JTU"OJNBUPSl!OVMMzʹ ͢Δͱ೚ҙͷߴ͞ʹͰ͖Δ
  8. &MFWBUJPOWT7JFX֊૚ w 7JFX͕ಉ͡FMFWBUJPOͳΒӨ͸ͳ ͘ͳΔ <LinearLayout android:layout_width="wrap_content" android:layout_height=“wrap_content" android:orientation="vertical"> <TextView android:elevation="8dp"

    android:padding="4dp" android:gravity=“center" android:layout_width="wrap_content" android:layout_height="@dimen/grid_size" android:background="@android:color/holo_green_dark" /> <TextView android:elevation="8dp" android:padding="4dp" android:gravity="center" android:layout_width="wrap_content" android:layout_height="@dimen/grid_size" android:background="@android:color/holo_blue_dark" /> </LinearLayout>
  9. &MFWBUJPOWT7JFX֊૚ w 7JFX֊૚͕ҧ͏ͱಉ͡FMFWBUJPOͰ΋ Ө͕ண͘ <LinearLayout android:layout_width="wrap_content" android:layout_height=“wrap_content" android:orientation="vertical"> <TextView android:elevation="8dp"

    android:padding="4dp" android:gravity=“center" android:layout_width="wrap_content" android:layout_height="@dimen/grid_size" android:background="@android:color/holo_green_dark" /> <LinearLayout android:layout_width="wrap_content" android:layout_height=“wrap_content" android:orientation="vertical"> <TextView android:elevation="8dp" android:padding="4dp" android:gravity="center" android:layout_width="wrap_content" android:layout_height="@dimen/grid_size" android:background="@android:color/holo_blue_dark" /> </LinearLayout> </LinearLayout>
  10. &MFWBUJPOWT7JFX֊૚ w ಉ͡FMFWBUJPOͷ͸͕ͣʜ w "DUJPO#BSͱλϒ͕ҧ͏ ֊૚ʹ͋Δ w 'SBHNFOUʹ5PPMCBSΛ
 ஔ͘Α͏ʹߏ੒Λม͑· ͨ͠ʜ

    ͳʹ͜Ε
  11. &MFWBUJPOWT7JFX֊૚ w ಉ͡FMFWBUJPOͷ͸͕ͣʜ w "DUJPO#BSͱλϒ͕ҧ͏ ֊૚ʹ͋Δ w 'SBHNFOUʹ5PPMCBSΛ
 ஔ͘Α͏ʹߏ੒Λม͑· ͨ͠ʜ

    "DUJWJUZ 'SBHNFOU ͳʹ͜Ε
  12. "DUJPO#BSͷλϒͰӨ͕ग़ͳ͍ w /"7*("5*0/@.0%&@5"#4ͰӨ ͕ग़ͳ͍ w ͦ΋ͦ΋͔Β%FQSFDBUFE w Ͳ͏ͯ͠΋࢖͍͚ͨΕ͹ແཧ໼ཧ
 ग़͢͜ͱ͸Մೳ ActionBarContainer

    container = 
 (ActionBarContainer) getWindow().findViewById(R.id.action_bar_container); container.setBackgroundColor(getResources().getColor(R.color.actionbar_background));
  13. ·ͱΊ w FMFWBUJPO͸7JFXͷߴ౓Λද֓͢೦ w Ө͕ࢥͬͨΑ͏ʹग़ͳ͍৔߹͸ҎԼΛ֬ೝ w Ϛʔδϯ w എܠ৭ͷΞϧϑΝ஋ w

    7JFX֊૚ w /"7*("5*0/@.0%&@5"#4΍ΊΑ͏