gpt4 book ai didi

android - PopupWindow 中的 Horizo​​ntalScrollView

转载 作者:行者123 更新时间:2023-11-30 04:08:33 25 4
gpt4 key购买 nike

我尝试使用 preView 创建 popupWindow,用户可以在其中查看图库中的图像。但是第一张和第二张图片是隐藏的,并且在 scrollView 的末尾是空白区域,就像屏幕截图中一样。

enter image description here

我正在尝试使用
layout.addView(imageView);

private void showAttachmentPopup() {
LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.attachemnts_file_popup, null, false);
PopupWindow pw = new PopupWindow(popupView, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.BELOW, findViewById(R.id.layout_sent).getId());
popupView.setLayoutParams(params);
LinearLayout layout_attachment = (LinearLayout) popupView.findViewById(R.id.layout_attachment);
RoundedImageView roundedImageView = new RoundedImageView(this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
lp.setMargins(5, 5, 5, 5);
roundedImageView.setLayoutParams(lp);
roundedImageView.setScaleType(RoundedImageView.ScaleType.FIT_XY);
roundedImageView.setImageBitmap(bitmap);
layout_attachment.addView(roundedImageView);

pw.setOutsideTouchable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.showAtLocation(mBtnAttach, Gravity.BOTTOM | Gravity.LEFT, locateView(mBtnAttach).bottom, locateView(mBtnAttach).right);
}

如果我几次尝试添加此位图,就会发生此错误。在我的 xml 中,只是将 Horizo​​ntalScrollView 和 LinearLayout 放到这里

最佳答案

我(猜)我有同样的问题,看起来一样。

对我有帮助的是设置 adjustViewBounds:

roundedImageView.setAdjustViewBounds(true);

希望它适合您的情况!

关于android - PopupWindow 中的 Horizo​​ntalScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11228823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com