ImageViewのセットを含むGridViewがあります。GetViewで次のように画像を作成します。
public override View GetView(int position, View convertView, ViewGroup parent)
{
ImageView imageView;
if (convertView == null)
{ // if it's not recycled, initialize some attributes
imageView = new ImageView(context);
imageView.LayoutParameters = new GridView.LayoutParams(118, 132); // images are all the same dimension
imageView.SetScaleType(ImageView.ScaleType.FitXy);
imageView.SetPadding(5, 5, 5, 0);
}
else
{
imageView = (ImageView)convertView;
}
imageView.SetImageResource(thumbIds[position]);
return imageView;
}
// references to our images
int[] thumbIds =
{
Resource.Drawable.IconAdvocacy, Resource.Drawable.IconBusinessServices,
Resource.Drawable.IconContactUs, Resource.Drawable.IconDistrict,
Resource.Drawable.IconEvents, Resource.Drawable.IconFind,
Resource.Drawable.IconLawsRegs, Resource.Drawable.IconHealth,
Resource.Drawable.IconPracMgmt, Resource.Drawable.IconPublications,
Resource.Drawable.IconUpdates, Resource.Drawable.IconUploadPhoto
};
ご覧のとおり、LayoutParams関数で固定サイズが定義されています。これにより、すべてのデバイスで画像のサイズが同じになります。
質問:画像を拡大縮小するための最良の方法は何ですか?
1)ドローアブル、-hdpi、-ldpi、および-mdpiフォルダーのそれぞれに異なるサイズの画像を作成するだけですか?その場合、LayoutParamsにサイズを指定するにはどうすればよいですか?
2)DisplayMetricsを取得しますか?もしそうなら、どうすればいいですか?これを行う方法に関するMonoDroid情報を取得できませんでした。ドキュメントの例は機能していないようです。
どんな助けでも大歓迎です!!
ありがとうございました