1

In my app, I want to implement a screen which should contain some buttons and as a background of the screen, I want a surface view which will show some animation. For this i have extended surface view which shows animation. The problem I am facing is, when i add some buttons, they are not fully opaque. They remain transparent and i can see the background animation through them. I tried setting background colour of the button to #FF000000, still it wasn't fully opaque.

Here is my activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/bg_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <com.myproj.example.widgets.CustomSurfaceView
            android:id="@+id/surface_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/test_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="#FF000000"
                android:text="Should be Opaque" />
        </RelativeLayout>
    </FrameLayout>

</RelativeLayout>

I have tried Android:How to add a button in surface view, Rendering a button over SurfaceView, but button is still not opaque.

Community
  • 1
  • 1
Aks
  • 11
  • 1
  • While playing with Grafika I found that certain themes had partially-transparent UI elements. If I switched to `android:theme="@android:style/Theme.NoTitleBar.Fullscreen"`, the widgets lost their transparency. – fadden Feb 25 '15 at 17:03
  • Have you solved it? I asked a similar question. http://stackoverflow.com/questions/29266322/make-linearlayout-in-framelayout-opaque – Amio.io Mar 25 '15 at 21:12

2 Answers2

0

Try adding an opaque "Drawable" as the background of the button.

amahfouz
  • 2,328
  • 2
  • 16
  • 21
  • Tried cropped version of [this](http://flagartist.com/SVG/Art/PIRATE/pirate_emanuel_wynne_colour_color_bw_black_opaque_peace-999px.png). Still transparent. – Aks Feb 25 '15 at 09:36
0

Use background color as #80000000 -

 <Button
            android:id="@+id/test_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="#80000000"
            android:text="Should be Opaque" />
Ravi Bhandari
  • 4,682
  • 8
  • 40
  • 68