开发者

Android want to create a transparent menu

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 - 开发者_C百科 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.


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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜