Created
May 11, 2015 08:24
-
-
Save douzifly/7fa56b3857bc08c9a6ed to your computer and use it in GitHub Desktop.
relayout ImageView with image size after image donwloaded
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dialog dialog = new Dialog(this); | |
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); | |
dialog.setContentView(R.layout.test_dialog); | |
RecyclingImageView imageView = (RecyclingImageView) dialog.findViewById(R.id.dialog_header); | |
String url = "http://x.png"; | |
DisplayImageOptions opts = RecyclingImageView.cloneDefaultOption(); | |
opts.imageScaleType = ImageScaleType.NONE; | |
opts.displayer = new BitmapDisplayer() { | |
@Override | |
public void display(RecyclingBitmapDrawable bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { | |
ViewGroup.LayoutParams lp = imageAware.getWrappedView().getLayoutParams(); | |
int viewWidth = imageAware.getWidth(); | |
int viewHeight = (int) ((float)(bitmap.getBitmap().getHeight()) / bitmap.getBitmap().getWidth() * | |
viewWidth); | |
lp.width = viewWidth; | |
lp.height = viewHeight; | |
imageAware.getWrappedView().requestLayout(); | |
imageAware.setImageBitmap(bitmap); | |
} | |
}; | |
imageView.loadUrl(url, opts); | |
dialog.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment