可変サイズのポップ ウィンドウを表示したい。レイアウトは EditView で構成され、ポップアップ ウィンドウを表示する前に実行時にテキストを設定します。新しいレイアウトの高さが欲しい。次のコードを使用しています。私が間違っている場所や、問題を解決するための間違ったアプローチを誰かが助けてくれますか?
onsizechange メソッドは常に yOld および yNew Zero を返します。
private void info(String name, String Description, View v) {
LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View popupView = layoutInflater.inflate(R.layout.lo_popup_concerninfo, null, false); final LinearLayout ll = (LinearLayout) popupView.findViewById(R.id.lo_popup_concern_linearlayout); TextView tv_concernName = (TextView) popupView .findViewById(R.id.tv_concernName); final TextView tv_concernDesc = (TextView) popupView .findViewById(R.id.tv_concernDesc); Button btn_concernDone = (Button) popupView .findViewById(R.id.btn_concernDone); tv_concernName.setText(name); tv_concernDesc.setText(Description); ll.addView(new MyCustomView(getActivity().getApplicationContext())); Display display = getActivity().getWindowManager().getDefaultDisplay(); //popupView.measure(display.getWidth(), display.getHeight()); popupView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); System.out.println("view.getMeasuredWidth() " + popupView.getMeasuredWidth()); System.out.println("view.getMeasuredHeight() " + popupView.getMeasuredHeight()); final PopupWindow popup = new PopupWindow(popupView, display.getWidth() - 40, popupView.getMeasuredHeight() + finalHeight); System.out.println("view" + popup.getHeight()); popup.showAtLocation(v, Gravity.CENTER, 0, 10); popup.setFocusable(true); popup.update(); class MyCustomView extends View{ int viewWidth = 0; int viewHeight = 0; public MyCustomView(Context context) { super(context); System.out.println("ali1"); } @Override protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld){ super.onSizeChanged(xNew, yNew, xOld, yOld); viewWidth = xNew; viewHeight = yNew; System.out.println("xNew " + xNew); System.out.println("yNew " + yNew); System.out.println("xOld " + xOld); System.out.println("yOld " + yOld); } @Override protected void onDraw(Canvas canvas){ super.onDraw(canvas); String msg = "width: " + viewWidth + "height: " + viewHeight; System.out.println(msg); } }