No se puede establecer el fondo de PopupWindow a transparente
Tengo el siguiente código:
View child = getLayoutInflater().inflate(R.layout.contextual_menu_lp_activity, null) child.setBackgroundColor(getResources().getColor(R.color.transparent)); child.setBackgroundDrawable(new BitmapDrawable()); popup = new PopupWindow(MapViewActivity.this); popup.setContentView(child); popup.showAtLocation(MapViewActivity.mapView, Gravity.CENTER, 10,10); popup.setBackgroundDrawable(new BitmapDrawable()); child.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); popup.update(50, 50,child.getMeasuredWidth(), child.getMeasuredHeight());
Como usted puede ver, fijé la visión, y trato desesperadamente de hacer su fondo transparente.
- Barra de navegación translúcida (Android 4.4) - Mostrar contenido debajo
- Añadir un botón de imagen con fondo transparente
- Cómo configurar el fondo transparente para el botón de imagen en el código?
- GIF transparente en Android ImageView
- Fondo transparente para Android OpenGL ES
En el diseño xml, todos los relativelayouts reciben un fondo de color transparente.
Aquí está el xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@color/transparent" > <RelativeLayout android:id="@+id/ivDialogPopup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:paddingBottom="40dp" android:background="@drawable/new_pop_up_bk" > <Button android:id="@+id/btLivePolice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@+id/btSaveParkingLocation" android:layout_marginRight="4dp" android:layout_marginTop="8dp" android:background="@drawable/live_police_button_popup" /> <Button android:id="@+id/btSaveParkingLocation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_marginTop="8dp" android:layout_centerHorizontal="true" android:background="@drawable/parking_location_button" /> <Button android:id="@+id/btGetDirections" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:layout_marginTop="8dp" android:layout_toRightOf="@+id/btSaveParkingLocation" android:background="@drawable/directions_button" />
Aún así, el diseño principal de la vista (un diseño relativo) todavía tiene un fondo gris. (Anteriormente, estaba usando la clase de actividad normal y en el manifiesto tenía un tema transparente -la parte más importante de él era establecer este android: windowBackground a transparent- tengo que cambiarlo por un motivo diferente).
Cualquier ayuda es apreciada.
- Mostrar una actividad transparente en Android?
- Android: Transparencia PNG fallando con BitmapFactory.decodeStream (...) y carpeta de activos
- Vista transparente sobre ImageView
- Android ScriptIntrinsicBlur no desenfoca toda la imagen y genera un borde transparente
- AChartEngine fondo transparente
- Especificación de recortes transparentes en xml
- Totalmente transparente ActionBarSherlock utilizando el tema
- ¿Cómo puedo crear una actividad transparente en Android?
Lo que haces es crear un archivo png transparente (por ejemplo, clear.png) y colocarlo en tu carpeta drawables, luego llamar
yourPopUp.setBackgroundDrawable(getResources().getDrawable(R.drawable.clear));
De esta manera el popup sigue siendo descartable, lo cual no es el caso si intenta usar null.
También puede configurar el fondo transparente como a continuación. Esto funcionó para mí.
popup.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Intente usar el @android:style/Theme.Translucent
para su RelativeLayout
lugar de cambiar el color de background
.
Aquí hay algunas otras sugerencias.
Usar android: background = "@ null"
- Android table con más de una columna como iOS collectionView
- Registrar GCM de un proyecto de biblioteca