1、其内 de 子控件高宽度为 0?

1
2
3
4
5
6
7
AlertDialog.Builder builder = new AlertDialog.Builder(StoryActivity.this);
View view = LayoutInflater.from(StoryActivity.this).inflate(R.layout.dialog_qr_display, null, false);
ImageView iv = (ImageView)view.findViewById(R.id.iv);
AlertDialog dialog = builder.setView(view).setTitle("分享").create();
dialog.show();
iv.getWidth(); //为0
iv.getHeight(); //为0

通过下列代码解决

1
2
3
ViewGroup.LayoutParams pm = ivQR.getLayoutParams();
pm.width;//不为0
pm.height;//不为0