I need to put a TextView on top of a Button in a RelativeLayout, so i put the TextView before the Button, but it doesn't work
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="20pt"
android:layout_height="22pt"
android:layout_gravity="start"
android:layout_marginTop="4pt"
android:background="@drawable/rounded_numbers"
android:gravity="center"
android:text="1" />
<Button
android:id="@+id/peso_but"
android:layout_width="100pt"
android:layout_height="20pt"
android:layout_marginStart="17pt"
android:layout_marginTop="5pt"
android:background="@drawable/rounded_button"
android:backgroundTint="#3399ff"
android:fontFamily="@font/fira_sans_semibold"
android:text="Button"
android:textColor="#f5f5f5"
android:textSize="8pt" />
</RelativeLayout>
As I know, putting one object before another should work, but it doesn't
Try this you need to use FrameLayout for overlap views each other
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/peso_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#888"
android:backgroundTint="#3399ff"
android:text="Button"
android:textColor="#f5f5f5"
android:textSize="8pt" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/black"
android:textColor="@color/white"
android:gravity="center"
android:elevation="100dp"
android:text="1" />
</FrameLayout>