jaredrummler / Cyanea

A theme engine for Android
Apache License 2.0
1.45k stars 144 forks source link

Fragments in a viewpager not being themed properly. #44

Open ItsCalebJones opened 5 years ago

ItsCalebJones commented 5 years ago

I have three fragments in a FragmentStatePagerAdapter almost done exactly like the demo project, however none of the fragments are theming properly. The parent activity is themed properly and the primary and accent colors are working however the ?backgroundColor attribute is not.

https://github.com/ItsCalebJones/SpaceLaunchNow-Android/tree/dev-new-ui/mobile/src/main/java/me/calebjones/spacelaunchnow/ui/launchdetail

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/summary_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/material_card_edge_margin"
            android:animateLayoutChanges="true"
            android:padding="@dimen/material_card_edge_margin"
            android:visibility="visible"
            app:cardBackgroundColor="?backgroundColor"
            card_view:cardCornerRadius="4dp"
            card_view:cardElevation="@dimen/material_card_elevation_resting"
            card_view:cardPreventCornerOverlap="true"
            card_view:cardUseCompatPadding="true">

It seems to be very similar to https://github.com/jaredrummler/Cyanea/issues/41 where at runtime calling getCyanea() can return the correct colors which means I could manually set the colors for each view, however that defeats the purpose of a clean library.

Notice cardBackground is using correct dark styling: screenshot_1545329519

Now a fragment inside the viewpager is not using correct dark styling: screenshot_1545329547

From the fragment if I call the getBackground I can then set that color, but I'd also need to set all textViews as they are not being styled properly either.

ItsCalebJones commented 5 years ago

Ok i've somewhat reproduced the issue in the demo app:

Setup: Build the app and change the theme around.

https://github.com/ItsCalebJones/Cyanea/commit/6d9d6781c69adf45edb675ab02ed141a503b4a51

1) Launch the app 2) Tap the Chipgroup to start the DupMainActivity 3) Card background color which is set via the ?backgroundColor attribute should always match the view that is colored at runtime.

Actual Results:

Occasionally - the cards view is some other color.

screenshot_1545333394

ItsCalebJones commented 5 years ago

Any chance this could get looked at? As an explanation - the entire Background Color card in the screenshot above should be #00000 however the card is rendered with the default dark color.