私はプログラムで作成したImageView
を持っており、Picassoを使用してイメージを読み込みます。 ImageViewの高さと幅はWRAP_CONTENT
に設定されています。画像はかなり大きいので、メモリを節約するためにPicassoの.fit().centerCrop()
メソッドを使用したいと思います。しかし、メソッドを追加すると、画像が表示されず、WRAP_CONTENT
が原因であると考えられます。ここに私のコードは次のとおりです。私はこの上で見つけることができるPicasso .fit().WAAP_CONTENTで動作しないcenterCrop()
ImageView iv = new ImageView(getContext());
RelativeLayout.LayoutParams centerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
iv.setLayoutParams(centerParams);
Picasso.with(context)load(path).fit().centerCrop().into(iv); //if I remove .fit().centerCrop(), the images load just fine
唯一の情報は、それについてthis issue on GitHubだった - 問題は、それがV2.4に閉鎖されたと言いながら、一部の人々は、彼らがV2でそれを経験していると言ってコメントしています。 5。ここではアンジェラの提案ごとに、私が今使っているものです::
ImageView iv = new ImageView(getContext());
RelativeLayout.LayoutParams centerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(350));
centerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
iv.setLayoutParams(centerParams);
iv.setAdjustViewBounds(true);
iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
Picasso.with(getContext()).load(path).fit().into(iv);
イメージが今現れ、彼らはスケーリングされていない
EDITを(私もV2.5を使用しています)適切に、アスペクト比は何とか変更されます。アスペクト比を維持する方法についてのアイデアは、ピカソが.fit()
の測定値を得ることを許可していますか?
ありがとう! :)イメージは今ロードされますが、私はそれらを適切にスケーリングすることはできません、アスペクト比は上に更新されたコードを変更し続ける。 – weirdo16
私のために働いていない。 –