1

ユーザーがギャラリーから画像を表示できる preView で popupWindow を作成しようとしています。しかし、1 番目と 2 番目の画像は非表示になり、scrollView の最後はスクリーンショットのように空白になります。

ここに画像の説明を入力

私は
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だけをここに入れます

4

1 に答える 1

1

私は(推測)私は同じ問題を抱えていました、同じように見えました。

私を助けたのは、adjustViewBoundsを設定することでした。

roundedImageView.setAdjustViewBounds(true);

それがあなたのケースに合うことを願っています!

于 2012-08-01T15:41:06.337 に答える