After applying new style for textView, default attrs are cleared
Kolyall opened this issue · comments
version 1.3.0
layout:
<TextView
android:id="@+id/titleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/textColorPrimary"
android:textSize="12sp"
/>
MyView.java
@Styleable("MyView")
@Layout(R.layout.view_my)
public class MyView extends LinearLayout implements View.OnClickListener {
@StyleableChild(R.styleable.MyView_titleViewStyle)
@BindView(R.id.titleView)
TextView mTitleView;
public void setStyleId(@StyleRes int styleId) {
Paris.style(this).apply(styleId);
}
}
styles.xml
<!--region Declare-->
<declare-styleable name="MyView">
<attr name="titleViewStyle" format="reference"/>
</attr>
</declare-styleable>
<!--endregion-->
<style name="MyView.Big">
<item name="titleViewStyle">@style/TitleStyle.Big</item>
</style>
<style name="TitleStyle.Big">
<item name="android:textSize">18sp</item>
</style>
Activity onCreate():
MyView view = new MyView(parent.getContext());
view.setStyleId(R.style.MyView_Big);
[bug]: By style (TitleStyle.Big) I changed only textSize, but in result textColor becomes to default, my android:textColor="@color/textColorPrimary"
is cleared
I'm not 100% sure, but I think I might be seeing a similar bug - I have two side-by-side Button
s in a ConstraintLayout
chain, and applying a style to one of them (via Paris.style(button).apply(R.style.whatever)
) ends up clearing the necessary CL attributes to make the chain work properly.
@airbnb any update?
@Kolyall I think this is linked to a textAppearance
issue which was introduced in 1.3.0
. Some styles seem to include a default textAppearance
value, which Paris now applies and that would result in the "clearing" effect you noted. Can you confirm whether or not you still experience this when using 1.2.1
(or any earlier version)? Thank you.
@mitchware-cfa I don't believe those issues are related. Would you mind creating a new one for the bug you're experiencing? Thank you.
@Kolyall this turns out to be expected behavior, I've added documentation about it as well as possible workarounds here: https://github.com/airbnb/paris/wiki/Building-and-Applying-Styles#themes