안드로이드 b/c에서 갤러리 위젯을 사용하는 대신 사용자 정의 가로 스크롤보기 갤러리를 만들려고합니다. API 16에서 사용되지 않습니다. 스크롤보기에서 이미지를 추가 할 수는 있지만 크기를 어떻게 변경합니까 이미지보기시 가로 스크롤 view.Here에서 이미지의 각각의 작은 이미지에 사용자가 클릭 코드가로 이미지보기 갤러리
private Integer[] Imgid = {
R.drawable.monk1,
R.drawable.mon2,
R.drawable.mon3,
};
LinearLayout linearLayout1 = (LinearLayout) findViewById(R.id.Linear);
for(x=0;x<15;x++) {
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),Imgid[x]);
int width = bitmapOrg.getWidth();
int height = bitmapOrg.getHeight();
int newWidth = 200;
int newHeight = 200;
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
matrix.postRotate(0);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,
width, height, matrix, true);
BitmapDrawable bmd = new BitmapDrawable(getResources(),resizedBitmap);
ImageView imageView = new ImageView(this);
imageView.setPadding(2, 0, 9, 5);
imageView.setImageDrawable(bmd);
imageView.setTag(x);
imageView.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
imgView.setImageResource(Imgid[]); // large imageview
}
});
linearLayout1.addView(imageView);
}
아니요, 왜 필요합니까 ?? – user2451541
이미지 뷰의 크기를 늘리시겠습니까? 또는 이미지를 미리 보시겠습니까? – dtheo