opened
bilifo
username_0
在设置与控件上方显示时,getHeight()==-2,即获得的值是无效的
关于设置在控件上方时,getHeight()=-2的解决
issue
closed
bilifo
username_0
issue
created
bilifo
username_0
原代码:
View contentView = LayoutInflater.from(getActivity()).inflate(R.layout.pop_list, null);
handleListView_ck(contentView, 4);//**向popWindow添加显示内容
CustomPopWindow popWindow = new CustomPopWindow.PopupWindowBuilder(this)
              .setView(contentView )
              .create();
popWindow .showAsDropDown(mButton2,0,  - (mButton2.getHeight() + popWindow.getHeight()));

解决:
View contentView = LayoutInflater.from(getActivity()).inflate(R.layout.pop_list, null);
handleListView_ck(contentView, 4);//**向popWindow添加显示内容

//解决contentView.getHeight()获取不到值的解决方式
contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

CustomPopWindow popWindow = new CustomPopWindow.PopupWindowBuilder(this)
              .setView(contentView )
              .create();
popWindow .showAsDropDown(mButton2,0,  - (mButton2.getHeight() + contentView.getMeasuredHeight()));
comment