PopupWindow.getContentView (). GetLayoutParams () returns another class in Android Marshmallow

I have a code like below.

....
PopupWindow popupWindow = new PopupWindow(someView);
final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) popupWindow.getContentView().getLayoutParams();
....

The problem is popupWindow.getContentView (). getLayoutParams returns differnt classes, as shown below, due to which my type does not work

Before Marshamallow: android.View.WindowManager.LayoutParams

For Marshmallow: android.widget.FrameLayout.layoutParams

Has anyone encountered a problem before or any resolutions?

+4
source share
1 answer

It is right. M completes everything inside FrameLayout called mDecorView. If you delve into the source of PopupWindow, you will find something like createDecorView(View contentView). The main goal mDecorViewis to handle event transitions and content transitions that are new to M.

, :

View container = (View) popupWindow.getContentView().getParent(); container.getLayoutParams();

, contentView null, . : (View) popupWindow.getContentView().getParent().getParent();

+4

Source: https://habr.com/ru/post/1614110/


All Articles