Issue
I am trying to figure out why my view appears to shift up after returning to an activity's screen.
Here is the image before navigating away to another fragment.
src="https://i.stack.imgur.com/n7OGU.png" alt="enter image description here" />
Here is the image after navigating back to original screen:
The xml file of the activity is:
<layout
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
/>
<androidx.constraintlayout.widget.ConstraintLayout
.
.
.
</androidx.constraintlayout.widget.ConstraintLayout>
.
.
.
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Note that I cannot use fitsSystemWindows=true
because I don't want to create a border at the top of the toolbar, the UI should have a continuous white background from behind the status bar.
Also, there is no keyboard present on the screen to cause this shift.
Solution
Add this to you root layout
android:fitsSystemWindows="true"
And set this to your AppTheme
<item name="android:windowTranslucentStatus">false</item>
Answered By - Noban Hasan
Answer Checked By - Robin (JavaFixing Admin)