2012-06-27 121 views
1

我嘗試使用preView創建popupWindow,其中用戶可以從庫中看到圖像。 但是第一張和第二張圖片是隱藏的,在scrollView的末尾是像截圖一樣的空白空間。PopupWindow中的Horizo​​ntalScrollView

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到這裏

+0

可以請你發佈一些你的代碼。 –

回答

1

我(猜)我有同樣的問題,看起來一樣。

什麼幫了我的流量比爲adjustViewBounds:

roundedImageView.setAdjustViewBounds(true); 

希望它適合你的情況!

相關問題