Skip to content

Setting style overrides attributes in XML layout #167

@UkiUros

Description

@UkiUros

If using my custom view, with some attributes (like gravity, maxLines, etc.) in the XML layout file and set some style for it using Paris lib, all these attributes are getting reset even when they are not in the new style.

Example:

<com.example.views.CustomTextView
    android:id="@+id/textViewFeedback"
    style="@style/Headline2"
    android:layout_width="@dimen/custom_diameter"
    android:layout_height="@dimen/custom_diameter"
    android:gravity="center"
    android:maxLines="3"
    android:paddingLeft="30dp"
    android:paddingRight="30dp"/>

If I set a new style using this line of code textViewFeedback.style(R.style.Headline1), attributes like gravity are getting overriden even if I do not have that field in my new style Headline1.

Is there a way to preserve these values?

P.S. I actually have more complex logic within the custom view, where I set the styles in the init block, for some cases, but I do not use any custom attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions