i try to create popupWindow with preView where user can see images from gallery. But first and second images are hiden and at the end of scrollView is empty space like in a screenshot.
I am try to use
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);
}
And if I try to add this bitmap few time this error happens. In my xml just HorizontalScrollView and LinearLayout into here
I ( guess ) i had the same issue, looked the same.
What helped me out was to set adjustViewBounds:
roundedImageView.setAdjustViewBounds(true);
Hope it suits your case!