4

I have a problem with background on activities and fragments when I use background in App theme:

<item name="android:colorBackground">@android:color/white</item>
<item name="android:windowBackground">@android:color/white</item>

When I put this on my theme and navigate between fragments with animation make a strange shadow:

enter image description here

This is normal? I have a transaction animation between fragments:

//add fragment
supportFragmentManager.beginTransaction().setCustomAnimations(
    R.anim.enter,
    R.anim.exit,
    R.anim.pop_enter,
    R.anim.pop_exit
).replace(R.id.fragment_container,fragmentToShow)
 .addToBackStack(null).commit()

If I remove the animation fragment, shadow overlap previous fragment (is worst then the animation is not the problem):

enter image description here

All base theme app is:

<style name="Base.Theme.App" parent="Theme.AppCompat.DayNight">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowLightStatusBar" tools:ignore="NewApi">true</item>
    <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>

    <item name="windowActionBarOverlay">true</item>

    <item name="colorControlNormal">@color/secondaryColor</item>
    <item name="android:colorBackground">@android:color/white</item>


    <!-- Styles of text -->
    <item name="android:textColor">@color/colorText</item>
    <item name="android:textSize">18sp</item>
    <item name="android:fontFamily">@font/montserrat_regular</item>

    <!-- CheckBox style -->
    <item name="android:checkboxStyle">@style/MyCheckBoxStyle</item>

    <!-- styles of button -->
    <item name="android:textAllCaps">false</item>

</style>

The shadows disappear after seconds in both cases... Can you help me, please?

Rahul Gaur
  • 1,661
  • 1
  • 13
  • 29
Jose Pose S
  • 1,175
  • 17
  • 33

2 Answers2

0

If I remove the animation fragment, shadow overlap previous fragment (is worst then the animation is not the problem):

I had the same issue with one of my old app. I found the issue was with fragments, they have a transparent background. You have to set the background color to fragments to stop them by showing previous activity or fragment contents.

Try doing

fragment.getView().setBackgroundColor(YOUR COLOR CHOICE);

maybe this can also help you out

Blu
  • 821
  • 4
  • 17
0

try this,

apply background color white to your fragment's parent layout

Ronak Ukani
  • 603
  • 5
  • 20