Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Margins defined in style.xml get ignored when using ContextThemeWrapper #417

Open
xoif opened this issue Mar 19, 2018 · 0 comments
Open
Labels

Comments

@xoif
Copy link

xoif commented Mar 19, 2018

Issues and steps to reproduce

  1. define Style for your view element (e.g. TextView):
<style name="style_text_black">
        <item name="android:textSize">12</item>
        <item name="android:textColor">@android:color/black</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginBottom">8dp</item>
        <item name="android:padding">8dp</item>
    </style>
  1. initialize ContextThemeWrapper to load the style
    ContextThemeWrapper themeWrapper = new ContextThemeWrapper(flexbox.getContext(),R.style.style_text_black);

  2. Create multiple new Textview instances and add them to FlexboxLayout

for (...) {
  TextView text = new TextView(themeWrapper);
                            text.setText("test");
  flexbox.addView(text);
}

Expected behavior

TextView elements appear in the flexbox layout while considering the margins from the applied style.

Observed behavior

Margins applied by a style using ContextThemeWrapper are ignored

I agree that this might be kind of an edge case, but it took me a few minutes of trying and browsing. Finally I ended up adding separate MarginLayoutParams to my Textviews.

Version of the flexbox library

flexbox:0.3.2

@thagikura thagikura added the bug label Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants