こんにちは、ギャラリー/カメラの画像を使用してページを追加または削除できる水平ギャラリーのようなものを構築しようとしています。
大きなビットマップで動作するようにしようとしているので、アルゴリズムを使用してビットマップをスケーリングし、各ページのイメージビューに設定しています。アルゴリズムには、ImageView の幅/高さが必要です (縮小するため)。
私が抱えている問題は、カスタム PagerAdapter メソッドが実行されたときに、ImageView の幅/高さが不明であるため (getWidth/getHeight が 0 を返す)、機能しないことです。
public Object instantiateItem(ViewGroup collection, int position) {
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.document_page, null);
((ViewPager) collection).addView(view, 0);
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
// Obtain the image file URI
// Call algorithm to get scaled bitmap using ImageView width and height --> PROBLEM: imageView.getWidth()/Height() return 0!!
// Set ImageView with scaled bitmap to avoid OutOfMemory Exception
return view;
}
何を指示してるんですか?
ありがとう。