Show TextView always on top
android, java, view
Solution
Use `FrameLayout` to set `TextView` over your `buttons` or `RelativeLayout`.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout ...>
// YOUR LAYOUT WITH BUTTONS
</LinearLayout>
<TextView
android:text="TEXT OVER BUTTONS"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"/>
</FrameLayout>
Problem
In my app, I´ve got 20 buttons that cover the whole display. Always one of them is visible and every second another one is shown. This should be a little game. Now, I need to add a score `TextView` so that the user knows, how much points he has at the moment. What is the best way to realize that? Like I said, the whole display is covered with the 20 buttons. Here´s the first Row of my TableLayout: ``` <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:background="@drawable/bg"> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/te" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="70dp" android:background="@drawable/te" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="140dp" android:background="@drawable/te" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="210dp" android:background="@drawable/te" /> </TableRow> ```