0

I have seen some posts regarding transparent menu.

I am able to change the background color of menu using the code given in the following link - Customizing the Options Menu Background

When I tried to change the background as transparent in the same code like given below, its not working

view.setBackgroundResource(R.drawable.full_trans_bg); 

instead of a normal image I have tried the transparent image, but its not working.

I just want to change the background color alone not the rest. Bcas I know to get this transparent background by inflating a new layout in the onCreateOptionsMenu() but in this case I want to do everything manually, which is not a motive.

Thanks in advance.

Padma
  • 656
  • 3
  • 11
  • 30

3 Answers3

1

Create a style in styles.xml

  <style name="myApplicationCustomTheme" parent="@android:Theme">
       <item name="android:panelFullBackground">@android:color/transparent</item>
       <item name="android:windowNoTitle">true</item>
  </style>

Apply this to your manifest

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/myApplicationCustomTheme"
    android:debuggable="true"
>

Also refer to this post. Is it possible to make the Android options menu background non-translucent?

Community
  • 1
  • 1
danfelabs
  • 1,873
  • 1
  • 18
  • 23
0

You can use XML background color value #00ff0000 which is transparent in itself.

0

I don't know the full code, but try something like this:

  view.setBackgroundResource(new Drawable(new Bitmap(R.drawable.full_trans_bg).getBitmapdata()); 

That might help.

L.Butz
  • 2,466
  • 25
  • 44