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
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步