2013-07-15 1 views
0

안드로이드 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); 
} 

답변

0

당신은 다음과 같이 이미지를 볼 수있는 의도를 열어야이

같은 것을 할 필요가 :

의도 의도 = 새로운 의도 (Intent.ACTION_VIEW를); Uri uri = Uri.parse ("android.resource : //your.package.name/"+ R.drawable.monk1,) intent.setData (uri); startActivity (intent);

0

클릭을 할 때 당신이 이미지 뷰에 레이아웃 PARAM을 설정하려고 적이있다?

+0

아니요, 왜 필요합니까 ?? – user2451541

+0

이미지 뷰의 크기를 늘리시겠습니까? 또는 이미지를 미리 보시겠습니까? – dtheo

관련 문제