I would suggest for you to use Constraint Layouts, I just tried it like this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.airbnb.lottie.LottieAnimationView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/animationLoading"
android:layout_width="200dp"
android:layout_height="200dp"
app:lottie_rawRes="@raw/thermosun"
app:lottie_loop="true"
app:lottie_autoPlay="true"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_margin="@dimen/app_default_margin_16dp"
android:text="My button"/>
</androidx.constraintlayout.widget.ConstraintLayout>
CustomTextView class
class CustomTextView : AppCompatTextView {
constructor(context: Context) : super(context) {
init(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs)
}
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(
context,
attrs,
defStyle
) {
init(context, attrs)
}
private fun init(context: Context, attrs: AttributeSet? = null) {
if (!isInEditMode) {
@Suppress("Recycle")
context.obtainStyledAttributes(attrs, R.styleable.AppCompatTextView).use {
setUpCharacterSpacing(
it.getFloat(R.styleable.CustomTextView_characterSpacing, 0.0f)
)
setUpLineSpacing(
it.getDimension(R.styleable.CustomTextView_lineSpacing, 0f)
)
}
paintFlags = paintFlags or Paint.SUBPIXEL_TEXT_FLAG
}
}
private fun setUpLineSpacing(lineSpacing: Float) {
if (lineSpacing != 0f) {
setLineSpacing(lineSpacing - textSize, 1f)
}
}
}
The XML with the Constraintlayout and the CustomTextView of the project
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/closeIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/ic_go_to_location"
android:layout_margin="@dimen/dimen_16dp"/>
<com.airbnb.lottie.LottieAnimationView
app:layout_constraintTop_toBottomOf="@id/closeIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/animationLoading"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="750:1080"
app:lottie_rawRes="@raw/thermosun"
app:lottie_loop="true"
app:lottie_autoPlay="true"/>
<com.shadows.howhotismycity.utils.CustomTextView
android:id="@+id/tvUserCounter"
android:layout_width="@dimen/dimen_30dp"
android:layout_height="wrap_content"
android:text="10"
android:textColor="@android:color/black"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/closeIcon"/>
<com.shadows.howhotismycity.utils.CustomTextView
android:id="@+id/tvSampleText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Theres some text here"
android:textColor="@android:color/black"
android:textSize="24sp"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvUserCounter"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_margin="@dimen/dimen_16dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Library dependency
//lottie
implementation 'com.airbnb.android:lottie:3.4.0'
Result of the textview on top of the animation tested in Android 10