Hier ist, wie ich ein PopupWindow
:PopupWindow Hintergrund wird manchmal transparent und lila
private static PopupWindow createPopup(FragmentActivity activity, View view)
{
PopupWindow popup = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
popup.setOutsideTouchable(true);
popup.setFocusable(true);
popup.setBackgroundDrawable(new ColorDrawable(Tools.getThemeReference(activity, R.attr.main_background_color)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
popup.setElevation(Tools.convertDpToPixel(8, activity));
PopupWindowCompat.setOverlapAnchor(popup, true);
return popup;
}
main_background_color
ist eine Farbe, weiß oder schwarz, je nach Thema. Manchmal passiert folgendes:
Wie kann ich das vermeiden? Es geschieht im Emulator mit Android 6 MANCHMAL nur zum Beispiel ... Normalerweise wird der PopupWindow
Hintergrund arbeitet, als ob zu erwarten ...
bearbeiten
Zusätzlich ist hier meine getThemeReference
Methode:
public static int getThemeReference(Context context, int attribute)
{
TypedValue typeValue = new TypedValue();
context.getTheme().resolveAttribute(attribute, typeValue, false);
if (typeValue.type == TypedValue.TYPE_REFERENCE)
{
int ref = typeValue.data;
return ref;
}
else
{
return -1;
}
}
EDIT 2 - das Problem lösen kann: getThemeColor
statt getThemeReference
Bitte posten Sie Ihre 'getThemeReference' Methode. –
Fertig. Dennoch glaube ich nicht, dass der Grund für das Problem darin liegt, da dies bedeuten würde, dass dieses Problem immer auftritt, aber es passiert nur selten (und bis jetzt sah ich es nur auf Android 6) – prom85