AlertDialog使用时遇到问题

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

    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

通过下列代码解决

    ViewGroup.LayoutParams pm = ivQR.getLayoutParams();
    pm.width;//不为0
    pm.height;//不为0
posted @ 2016-04-21 14:49  NeilLee  阅读(324)  评论(0编辑  收藏  举报