I have an upvote button on top of which I have to display the number of upvotes. I have used a ToggleButton for upvote and a textview to display the number of upvotes. I used a FrameLayout to overlap textview which shows number of followers on top of upvote button. But the textview is not getting overlapped. Instead it is hidden behind the upvote button.
Here is my FrameLayout:
<FrameLayout
android:layout_below="@id/position"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ToggleButton
android:id="@+id/thumbs_up"
android:textOff=""
android:textOn=""
android:checked="true"
android:layout_width="140dp"
android:layout_height="40dp"
android:background="@null"
android:button="@drawable/check"/>
<TextView
android:layout_marginLeft="100dp"
android:id="@+id/numberOfUpvotes"
android:text="120"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content" />
</FrameLayout>
Use android:elevation
attribute on your TextView
because the ToggleButton
has a default elevation that is why it's rendering above the TextView
.