I'm struggling with custom views defStyleAttr
. (Short note I'm using a Preference
as example cause it's the same way Google uses it)
So for almost every View
or Preference
that is provided by Android you'll have a constructor like this:
public SeekBarPreference(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.seekBarPreferenceStyle);
}
This defines the default style attribute to be R.attr.seekBarPreferenceStyle
.
If you now look into the definition you'll find this:
<attr name="seekBarPreferenceStyle" format="reference" />
Until now everything is clear. But this attribute is somehow linked to a theme:
<resources>
<style name="PreferenceThemeOverlay">
<!-- ... -->
<item name="seekBarPreferenceStyle">@style/Preference.SeekBarPreference.Material</item>
<!-- ... -->
</style>
<!-- ... -->
</resources>
Which then finally links a style with the needed layout resource id that will be handed over to the super class to be inflated:
<style name="Preference.SeekBarPreference.Material">
<item name="android:layout">@layout/preference_widget_seekbar_material</item>
<!-- ... -->
</style>
Unfortunately I wasn't able to find a hint on how the theme PreferenceThemeOverlay
is linked to the attribute seekBarPreferenceStyle
.
So how are these two linked?