2017-01-21 2 views
0

Meine Aktivität ein Popup-Fenster hat wie folgt definiert:Android: setOverlapAnchor vor API 23

this.navigationMenuPopupWindow = new PopupWindow(View.inflate(this, R.layout.popup_navigation, null), ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 
this.navigationMenuPopupWindow.setWidth((int) this.getResources().getDimension(R.dimen.navigation_popup_width)); 
this.navigationMenuPopupWindow.setBackgroundDrawable(this.getDrawable(R.drawable.main_bg_navigation_menu)); 
this.navigationMenuPopupWindow.setElevation(43); 
this.navigationMenuPopupWindow.setFocusable(true); 
this.navigationMenuPopupWindow.setOutsideTouchable(true); 

Ich möchte das Popup unter der Anker positionieren. So versuchte ich natürlich diese Zeile hinzufügen:

this.navigationMenuPopupWindow.setOverlapAnchor(false); 

Leider erfordert es die API 23. Wie kann ich das gleiche Ergebnis erzielen, aber das ist es kompatibel mit dem API 21?

Ich denke, ich kann das beheben, indem ich meine App-Stil ändern, aber ich weiß nicht genau wie. Das kann übrigens alle PopupWindows der App betreffen, es ist kein Problem, dass ich nur dieses habe. Danke für Ihre Hilfe!

+0

hat ich denke, das sollte helfen http://stackoverflow.com/questions/9467026/changing-position-of-the-dialog -on-Bildschirm-Android –

Antwort

0

Sie müssen PopupWindowCompat verwenden.

PopupWindowCompat.setOverlapAnchor(this.navigationMenuPopupWindow,true);

Beachten Sie, dass die PopupWindowCompat.setOverlapAnchor keine Implementierung vor API 21.

Verwandte Themen