XML Style is missing "textAppearance" attribute
malacavilla opened this issue · comments
I get the following runtime exception in version 1.3.0, whereas this was working back in version 1.2.1. I think the issue may have been introduced here: #111
Exception:
java.lang.IllegalStateException: CommonParisTextViewModel_ model at position 2 has an invalid style:
The CommonParisTextView style "a programmatic style" is missing the following attributes:
✕ textAppearance
It must declare the same attributes as the following styles:
FullScreenDialog.DisclaimerSection
at com.mypackage.CommonParisTextViewModel_$1.run(CommonParisTextViewModel_.java:127)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
Defined on our View (which extends AppCompatTextView
) we have the following:
companion object {
@Style
val DEFAULT_STYLE = commonParisTextViewStyle {
paddingBottom(0)
paddingStart(0)
paddingEnd(0)
paddingTop(0)
textSizeRes(R.dimen.text_size_normal)
textColorRes(R.color.text)
textAllCaps(false)
gravity(Gravity.START)
fontFamilyRes(R.font.basis)
textColorHint(R.color.text_hint)
lineSpacingMultiplierRes(R.dimen.text_view_line_spacing)
letterSpacing(0f)
}
@Style
val FULLSCREEN_DIALOG_SUB_TEXT = R.style.FullScreenDialog_SubText
@Style
val FULLSCREEN_DIALOG_SECTION_HEADER = R.style.FullScreenDialog_SectionHeader
@Style
val FULLSCREEN_DIALOG_DISCLAIMER_SECTION = R.style.FullScreenDialog_DisclaimerSection
}
And the related styles are:
<style name="TextView" parent="android:style/Widget.TextView">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/regular_text_size</item>
<item name="android:lineSpacingMultiplier">1.2</item>
</style>
<style name="FullScreenDialog.SubText" parent="TextView">
<item name="android:paddingEnd">@dimen/margin_typical</item>
<item name="android:paddingStart">@dimen/margin_typical</item>
<item name="android:paddingTop">@dimen/margin_typical</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:gravity">start</item>
<item name="android:textAllCaps">false</item>
<item name="android:letterSpacing">0</item>
</style>
<style name="FullScreenDialog.SectionHeader" parent="FullScreenDialog.SubText">
<item name="android:textAllCaps">true</item>
</style>
<style name="FullScreenDialog.DisclaimerSection" parent="FullScreenDialog.SubText">
<item name="android:textSize">@dimen/text_size_smaller</item>
</style>
You can see that both the XML and DEFAULT_STYLE
defined in code provide the same styleable attributes, however the XML version will crash at runtime stating that the textAppearance
is missing. My understanding is that any set of Paris style needs to define the same styleable attributes to work, however even when doing so I get an error about textAppearance
being missing.
@malacavilla thanks for the report. I plan on tackling this issue in the near future.
@malacavilla this should be fixed in 1.3.1
.