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

?

 ?

Bbe9718bebdafbdc8dabbe3cadf1bc46?s=128

Keishin Yokomaku

February 18, 2015
Tweet

Transcript

  1. ? @KeithYokoma - Drivemode, Inc. potatotips #14

  2. KeithYokoma Keishin Yokomaku Drivemode, Inc. Android Engineer GitHub: https://github.com/KeithYokoma Qiita:

    http://qiita.com/KeithYokoma e-Book: http://amzn.to/1mZNydv
  3. ?

  4. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?android:attr/listPreferredItemHeight”> <!—— content ——> </RelativeLayout>

  5. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?android:attr/listPreferredItemHeight”> <!—— content ——> </RelativeLayout>

  6. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?android:attr/listPreferredItemHeight”> <!—— content ——> </RelativeLayout>

  7. ?

  8. Referencing style attributes Allows us to reference the value of

    the attribute in the currently-applied theme. Format: ?[<package_name>:][<resource_type>/]<resource_name>
  9. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?android:attr/listPreferredItemHeight”> <!—— content ——> </RelativeLayout> <resources>

    <style name=“MyTheme” parent=“Theme.Light”> <item name=“android:listPreferredItemHeight”>64dp</item> </style> </resources>
  10. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?android:attr/listPreferredItemHeight”> <!—— content ——> </RelativeLayout> <resources>

    <style name=“MyTheme” parent=“Theme.Light”> <item name=“android:listPreferredItemHeight”>64dp</item> </style> </resources>
  11. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“64dp”> <!—— content ——> </RelativeLayout> <resources>

    <style name=“MyTheme” parent=“Theme.Light”> <item name=“android:listPreferredItemHeight”>64dp</item> </style> </resources>
  12. Your own “?”

  13. <resources> <attr name=“my_custom_attribute” format=“reference”/> </resources>

  14. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?attr/my_custom_attribute”> <!—— content ——> </RelativeLayout>

  15. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?attr/my_custom_attribute”> <!—— content ——> </RelativeLayout> <resources>

    <style name=“MyTheme” parent=“Theme.Light”> <item name=“my_custom_attribute”>64dp</item> </style> </resources>
  16. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“?attr/my_custom_attribute”> <!—— content ——> </RelativeLayout> <resources>

    <style name=“MyTheme” parent=“Theme.Light”> <item name=“my_custom_attribute”>64dp</item> </style> </resources>
  17. <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width=“match_parent” android:layout_height=“wrap_content” android:minHeight=“64dp”> <!—— content ——> </RelativeLayout> <resources>

    <style name=“MyTheme” parent=“Theme.Light”> <item name=“my_custom_attribute”>64dp</item> </style> </resources>
  18. Abstract Theme Using style attributes reference. ✓ Reduce costs to

    change styles ✓ Reusable styling
  19. themes_holo.xml <resources> <style name=“Theme.Holo”> <—— … ——> <item name="colorPrimary">@color/holo_primary</item> <item

    name=“colorEdgeEffect”>?attr/colorPrimary</item> <—— … ——> </style> </resources>
  20. themes_holo.xml <resources> <style name=“Theme.Holo.Light” parent=“Theme.Light”> <—— … ——> <item name="colorPrimary">@color/holo_light_primary</item>

    <—— … ——> </style> </resources>
  21. themes_holo.xml <resources> <style name=“Theme.Holo.Light” parent=“Theme.Light”> <—— … ——> <item name="colorPrimary">@color/holo_light_primary</item>

    <—— … ——> </style> <style name=“Theme.Holo.Light.DarkActionBar"> </style> </resources>
  22. –Ryan Brush “Code is design”

  23. ? @KeithYokoma - Drivemode, Inc. potatotips #14