我尝试了很多东西,但没有得到任何解决方案,我在运行时设置文本,我需要根据文本大小弹出的宽度
LinearLayout viewGroup =(LinearLayout)((Activity)context)
.findViewById(R.id.popup);
LinearLayout viewGroup =(LinearLayout)((Activity)context)
.findViewById(R.id.popup);
LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_layout,viewGroup); title_tv = (TextView) layout.findViewById(R.id.popup_txt); title_tv.setText(title_P); PopupWindow popup = new PopupWindow(context); final float SCALE = layout.getResources().getdisplayMetrics().density; int mode = MeasureSpec.getMode(View.MeasureSpec.UNSPECIFIED); int measuredWidth = MeasureSpec.getSize(View.MeasureSpec.UNSPECIFIED); popup.setWidth(measuredWidth); popup.setHeight(60); popup.setContentView(layout); //popup.setwindowLayoutMode(); popup.setFocusable(true);
解决方法
原文地址:https://www.jb51.cc/android/316699.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。