enter image description here Text in the ViewPager does not move. And the fragments are moving. The task is such that it is necessary to arrange the fragments in such a way that the ASD text is above the TEXT. In all fragments.

Of course, you can calculate and set values ​​using DP. But the problem with specifying static values ​​is that if you run it on a different layout, it looks awful and ASD fits on TEXT.

Using ReleativeLayout or ConstaintLayout, you can avoid this if the View components are in the same XML layout. What to do in this case?

Any ideas?

PS Type suggestions to install all VIew in one layout and after changing the text will not work, you need an animation ViewPager

  • The option not to make the ViewPager height of the whole page, but to make ASD below the text does not fit? Is there any content above it too? - eugeneek
  • @eugeneek, Suitable. But damn the whole problem in Backgoorund. Fragments in full screen Picture. That's the problem - user239760

1 answer 1

If they are the same for you, you can add a View with zero dimensions in the center in the desired layout and position the text relative to it:

 <RelativeLayout ...> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_centerVertical="true" android:layout_centerHorizontal="true" android:id="@+id/view" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView1" android:layout_below="@+id/view" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_marginRight="24dp" android:layout_marginEnd="24dp" /> </RelativeLayout> <RelativeLayout ...> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_centerVertical="true" android:layout_centerHorizontal="true" android:id="@+id/view" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView2" android:layout_above="@+id/view" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_marginRight="24dp" android:layout_marginEnd="24dp" /> </RelativeLayout> 

If it is necessary to shift a little about the center set for the first

 android:layout_marginTop=" больше 0dp" 

for the second

 android:layout_marginTop=" меньше 0dp" 

Result:

enter image description here