Android's approach to Device specific default themes and styles makes life easy for application developers targeting API level 14 and above. Android's style customization offers OEM to have their own look and feel. This was done by adding a new theme, DeviceDefault starting from Android 4.0 API (level 14). This theme is what enables OEMs to have their own native look and feel. An OEM wanting to have their own progress bar styles across the device can do so. Google’s Nexus devices uses unmodified Holo themes as the device default theme.
This new theme helps developers to target the device’s native theme with all OEM customizations intact without having to develop OEM specific application etc. Application developers can override these device default styles for their own requirements.
<style name="AppProgressBarStyle" parent="@android:style/Widget.DeviceDefault.ProgressBar">
...
...
...
</style>
<style name="AppProgressBarStyle.Light" parent="@android:style/Widget.DeviceDefault.Light.ProgressBar">
...
...
...
</style>
This scheme works as long as OEMs retain the same style name. The documentation in theme_device_defaults.xml claims that the styles used by the DeviceDefault theme are named using the convention Type.DeviceDefault.Etc (like Widget.DeviceDefault.Button and TextAppearance.DeviceDefault.Widget.PopupMenu.Large). In fact, small buttons have their own default style Widget.DeviceDefault.Button.Small. This style is set to buttonStyleSmall.
But what if an OEM decides to have another inherited style for buttonStyleSmall, like Widget.DeviceDefault.Button.Tiny? Although, this might work at a platform level, there is no way for application developer to use this via SDK. The predefined styles are exposed via Android SDK. In this case, OEMs are expected to update the style Widget.DeviceDefault.Button.Small and specify tiny button's properties in the Small style. This facilitates expected behavior across platform and application developers can still continue to use public style (Small but with OEM tiny customizations).
This new theme helps developers to target the device’s native theme with all OEM customizations intact without having to develop OEM specific application etc. Application developers can override these device default styles for their own requirements.
<style name="AppProgressBarStyle" parent="@android:style/Widget.DeviceDefault.ProgressBar">
...
...
...
</style>
<style name="AppProgressBarStyle.Light" parent="@android:style/Widget.DeviceDefault.Light.ProgressBar">
...
...
...
</style>
This scheme works as long as OEMs retain the same style name. The documentation in theme_device_defaults.xml claims that the styles used by the DeviceDefault theme are named using the convention Type.DeviceDefault.Etc (like Widget.DeviceDefault.Button and TextAppearance.DeviceDefault.Widget.PopupMenu.Large). In fact, small buttons have their own default style Widget.DeviceDefault.Button.Small. This style is set to buttonStyleSmall.
But what if an OEM decides to have another inherited style for buttonStyleSmall, like Widget.DeviceDefault.Button.Tiny? Although, this might work at a platform level, there is no way for application developer to use this via SDK. The predefined styles are exposed via Android SDK. In this case, OEMs are expected to update the style Widget.DeviceDefault.Button.Small and specify tiny button's properties in the Small style. This facilitates expected behavior across platform and application developers can still continue to use public style (Small but with OEM tiny customizations).
No comments:
Post a Comment