¾È±Ô °øºÎ¹æ

Android > ActionBar - ³×ºñ°ÔÀÌ¼Ç µå·Î¾î(Navigation Drawer) »ç¿ëÇϱâ

µî·ÏÀÏ : 2017-07-05 19:03 Á¶È¸¼ö : 53,004

ImageView À§Á¬¿¡ À̹ÌÁö¸¦ Ç¥½ÃÇÏ´Â ¹æ¹ýµé

Imageview ¿¡ À̹ÌÁö¸¦ Ç¥½ÃÇÏ´Â ¹æ¹ýÀº ¿©·¯°¡Áö°¡ ÀÖ´Ù.  Ç¥½ÃÇÏ´Â ¹æ¹ý ¶ÇÇÑ ¿©·¯°¡Áö°¡ ÀÖÀ¸¹Ç·Î ÇϳªÇϳª Á¤¸®¸¦ ÇØ ³õ¾Æ¾ß °Ú´Ù.


1. src : xml¿¡¼­ ±×³É º¸¿©ÁÖ´Â ¹æ½Ä
xml ¿¡¼­ src ¼Ó¼ºÀ» »ç¿ëÇؼ­ ÆÄÀÏÀ» ¼±ÅÃÇØ ÁÖ¸é µÈ´Ù.
 
        <ImageView
            android:id="@+id/img_imageview"
            android:layout_width="90dp"
            android:layout_height="120dp"
            android:layout_weight="0.25"
            android:src="@drawable/ic_launcher" />


2. setImageResource() : xml ¿¡´Â imageView ¸¸ Ãß°¡ÇÏ°í Activity¿¡¼­ º¸¿©ÁÖ´Â ¹æ½Ä
res/drawable Æú´õ¿¡ a.png ¶ó´Â ÆÄÀÏÀ» ³Ö¾îµÎ¾ú´Ù.

res ¸®¼Ò½º¸¦ Àоî¿Í »Ñ·ÁÁÖ´Â ¹æ½ÄÀÌ´Ù.
 
			ImageView iv = (ImageView)findViewById(R.id.iv);
			iv.setImageResource(R.drawable.a);


3. setImageDrawable() : ¸®¼Ò½º¿¡ ÀÖ´Â À̹ÌÁö¸¦ Activity·Î º¸¿©ÁÖ´Â ¹æ½Ä
res ¸®¼Ò½º À̹ÌÁö¸¦ Drawable °´Ã¼¸¦ »ý¼ºÇؼ­ Àоîµå¸°ÈÄ »Ñ·ÁÁÖ´Â ¹æ½ÄÀÌ´Ù.
			ImageView iv = (ImageView)findViewById(R.id.iv);

			Drawable drawable = getResources().getDrawable(R.drawable.icon);
			iv.setImageDrawable(drawable);



4. setImageBitmap() : ºñÆ®¸ÊÀ» »ç¿ëÇؼ­ Activity¿¡¼­ º¸¿©ÁÖ´Â ¹æ½Ä
 
			ImageView iv = (ImageView)findViewById(R.id.iv);

			Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
			iv.setImageBitmap(bm);



5. setImageBitmap() : SDÄ«µå³» ÆÄÀÏÀ» ºÒ·¯¿Í Ãâ·ÂÇÏ´Â ¹æ½Ä
 
			File f = Environment.getExternalStorageDirectory();
			String path  = f.getAbsolutePath();

			ImageView iv = (ImageView)findViewById(R.id.iv);

			Bitmap bm = BitmapFactory.decodeFile(path + "bm1.bmp");
			iv.setImageBitmap(bm);



6. setImageBitmap() : ¼­¹öÀ̹ÌÁö¸¦ Àоî¿Í º¸¿©ÁÖ´Â ¹æ½Ä
 
			try {
				Stirng urlString = "http://test.co.kr/test.gif";
				URL url = new URL(urlString);
				InputStream is = url.openStream();

				ImageView iv = (ImageView)findViewById(R.id.iv);
				Bitmap bm = BitmapFactory.decodeStream(is);
				iv.setImageBitmap(bm);
			} catch(Exception e) {
				e.printStackTrace();
			}

		


´õ ¸¹Àº ´Ù¾çÇÑ ¹æ¹ýµéÀÌ Á¸ÀçÇÏ´Ï °øºÎÇϴµ¥·Î Á¤¸®Çϵµ·Ï Çؾ߰ڴÙ.
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.