¾È±Ô °øºÎ¹æ

Android > resource - À̹ÌÁö ¸®¼Ò½º drawable

µî·ÏÀÏ : 2017-07-05 16:57 Á¶È¸¼ö : 53,261

À̹ÌÁö ¸®¼Ò½º´Â /res/drawable ¹Ø¿¡¼­ °ü¸®ÇÑ´Ù.

À̹ÌÁö ÆÄÀÏÀ» drawable ¹Ø¿¡ ³Ö¾îµÎ±â¸¸ ÇÏ¸é µÈ´Ù.

drawable Æú´õ´Â drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi µîÀÇ Æú´õ°¡ ÀÖ´Ù.

ÀÌ°ÍÀº ÀåºñÀÇ È­Áú¿¡ µû¸¥ ±¸ºÐÀ̸ç, È­Áú¿¡ µû¶ó ´Ù¸¥ À̹ÌÁö¸¦ ¸®¼Ò½º·Î °ü¸®ÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.

¶ÇÇÑ PNG ÆÄÀÏÀ» ±ÇÀåÇÏ°í ÀÖ´Ù.

ÀÌ¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ³»¿ëÀº  ¾Èµå·ÎÀ̵å(Android) res(¸®¼Ò½º) °ü¸® ¿¡¼­ Âü°íÇÏÀÚ

1. res(¸®¼Ò½º)¿¡ drawable À̹ÌÁö µî·ÏÇϱâ

µî·ÏÇÒ À̹ÌÁö¸¦ /res/drawable-XXX Æú´õ¿¡ ³Ö¾îµÐ´Ù.

¿©±â¼­´Â ¿¡¹Ä·¹ÀÌÅ͸¦ hdpi ¹öÀüÀÇ µð¹ÙÀ̽º¸¦ ¼±ÅÃÇ߱⿡, googlelogo.png ¿Í naverlogo.png ÆÄÀÏÀ» /res/drawable-hdpi ¿¡ ³Ö¾îµÎ¾ú´Ù.

ÆÄÀÏÀ» ³Ö¾îµÎ¸é À̹ÌÁö ÆÄÀÏ ¸®¼Ò½º µî·ÏÀÌ ³¡³­´Ù.

2. layoutÀÇ xml¿¡¼­ drawable À̹ÌÁö ¸®¼Ò½º °¡Á®¿À±â
 

	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
		xmlns:tools="http://schemas.android.com/tools"
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		android:paddingBottom="@dimen/activity_vertical_margin"
		android:paddingLeft="@dimen/activity_horizontal_margin"
		android:paddingRight="@dimen/activity_horizontal_margin"
		android:paddingTop="@dimen/activity_vertical_margin"
		tools:context=".MainActivity" >

		<ImageView
			android:id="@+id/imageView01"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:src="@drawable/googlelogo" />

	</RelativeLayout>


- id : imageView01 ·Î <ImageView< µî·Ï
- drawable ¸®¼Ò½ºÀÇ googlelogo ÆÄÀÏ µî·Ï ( android:src="@drawable/googlelogo"  )


½ÇÇàÈ­¸éÀ» º¸ÀÚ!


- googlelogo.png Ãâ·Â

3. Activity.java¿¡¼­ drawable À̹ÌÁö ¸®¼Ò½º °¡Á®¿À±â
 
	public class MainActivity extends Activity {

		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);

			// drawable ¸®¼Ò½º¿¡¼­ naverlogo ÆÄÀÏ È£Ãâ ÇÏ¿© Drawable¿¡ µî·Ï
			Drawable drawable = getResources().getDrawable(R.drawable.naverlogo);

			// id : imageView01 ImageView ¸¦ °¡Á®¿Â´Ù.
			// imageView01 ¿¡ ¸®¼Ò½º¿¡¼­ °¡Á®¿Â naverlogo µî·Ï
			ImageView imageView = (ImageView)findViewById(R.id.imageView01);
			imageView.setImageDrawable(drawable);
		}
	}
	


- getResources().getDrawable·Î ¸®¼Ò½º¿¡ ÀÖ´Â naverlogo ÆÄÀÏÀ» °¡Á®¿Â´Ù.
- ImageView ¸¦ È£ÃâÇÑ ÈÄ ImageView¿¡ È£ÃâÇÑ naverlogo ÆÄÀÏÀ» µî·ÏÇÑ´Ù.

½ÇÇàÈ­¸éÀ» º¸ÀÚ!


- naverlogo.png ÆÄÀÏ Ãâ·Â
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.