Android transparent image in popup is not transparent

I am trying to display a transparent image as a popup. To do this, I customized popupwindow to suit my needs and fanned the relative layout in that popupwindow initview ().

In this relative layout, I added a transparent image, but when I started the application, it is an oval image inside a rectangular block, so instead of transparency I could see a gray color around this oval image.

I have no option except popupwindow, because I have to use the controls on the background screen.

I tried to set a transparent style for this relative layout, although it doesn't work.

Can anyone tell me how to do this

or

There is an error in the android popup.

Thanks in advance.

+3
source share
4 answers

We found a solution for this - when setting up the popup, we must set the background to null. setBackgroundDrawable (zero); Then it worked.

+1
source

Use android themes in your popup. If this action declares it in the manifest.

Android: theme = "@ android: style /Theme.Translucent"

EDIT Set the theme for the dialog box.

mDialogTax = new dialog (mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);

+1
source

,

, :

inflatedView.setBackgroundColor(android.R.color.transparent);

, PopupWindow, , .

PopupWindow :

this.setBackgroundDrawable(null);p >

- :

this.getBackground().setAlpha(<value>);p >

, PNG, :

imageView.setBackgroundColor(android.R.color.transparent);p >

:

<ImageView  android:id="@+id/myimage"
            android:background="@android:color/transparent"
            />

Strike>

Thank...

0
source

There is a right solution. The problem is that against the background, popupWindow is defined in the style of the action theme.

Decision:

  • specify your theme for the application or activity displaying PopupWindow.

    • You can choose a different parent theme.
    • configure the entry "android: popupWindowStyle"

      <style name="CustomTheme" parent="@android:style/Theme.NoTitleBar">
          <item name="android:popupWindowStyle">@style/PopupWindow</item> 
      </style>
      
  • define popupWindowStyle. entry "android: popupBacground" define the background for all pop-ups with the specified theme.

    <style name="PopupWindow" parent="@android:style/Widget.PopupWindow">
         <item name="android:popupBackground">@color/transparent</item> 
    </style>
    
  • add CustomTheme theme to action or application

    <application
            ...
            android:theme="@style/CustomTheme" >
    

A popup will appear with a transparent background.

0
source

All Articles