How to superimpose TextView on Button in RelativeLayout?
- What you want to get from this overlay, for sure there is a better solution than the imposition of widgets on each other. - pavlofff
- I have a button that starts the timer. I want this button to count down the timer. @pavlofff - Leo Naumenko
- @LevNaumenko and you are not using AppCompat there? - ermak0ff
- I use. @ ermak0ff - Leo Naumenko
|
2 answers
All due to the fact that the buttons in the API > 21 have the android:elevation attribute, in consequence of which your button overlaps the TextView .
Add to your TextView attribute android:elevation = 2dp .
Read more here .
|
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button2" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="text" android:id="@+id/textView" android:drawablePadding="0dp" android:layout_alignTop="@+id/button2" android:layout_alignLeft="@+id/button2" android:layout_alignBottom="@+id/button2" android:layout_alignRight="@+id/button2" android:gravity="center" /> </RelativeLayout> - And how to make TextView on top of Button? @metalurgus - Leo Naumenko
- @LevNaumenko, it will be on top of
Button. To be sure - change the text color to it, or background - Vladyslav Matviienko - I do not know what I am doing wrong, but still the text under the button. @metalurgus - Leo Naumenko
|