jjzjj

getContentView

全部标签

android - 为什么 Activity 没有 getContentView() 方法?

Activity类有一个setContentView()方法。PopupWindow类有一个getContentView()方法,但没有其他方法。是否有另一种方法来获取Activity的主要内容View? 最佳答案 我能够通过这个调用获取Activity的内容:ViewGroupview=(ViewGroup)getWindow().getDecorView();您可能应该检查getDecorView是否在所有情况下都返回一个ViewGroup实例,但是在Activity中使用LinearLayout上面的代码运行正常。要获得Lin

android - PopupWindow.getContentView().getLayoutParams() 在 Android Marshmallow 中返回一个不同的类

我有如下代码。....PopupWindowpopupWindow=newPopupWindow(someView);finalWindowManager.LayoutParamslayoutParams=(WindowManager.LayoutParams)popupWindow.getContentView().getLayoutParams();....问题popupWindow.getContentView().getLayoutParams正在返回不同的类,因为我的类型转换失败了在Marshamallow之前:android.View.WindowManager.Layou

android - 为什么 Activity 没有 getContentView() 方法?

Activity类有一个setContentView()方法。PopupWindow类有一个getContentView()方法,但没有其他方法。还有其他方法可以获取Activity的主要内容View吗? 最佳答案 我能够通过此调用访问Activity的内容:ViewGroupview=(ViewGroup)getWindow().getDecorView();您可能应该检查getDecorView是否在所有情况下都返回一个instanceofViewGroup,但是在Activity中使用LinearLayout时,上面的代码运行