|
¡û ¤Ï¤¸¤á¤Ë
Android ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó(Activity) ¤Î UI ¤Ï¡¢android.view.ViewGroup ¤ª¤è¤Ó android.view.View ¤ò»È¤Ã¤¿¥Ä¥ê¡¼¹½Â¤¤ÇÄêµÁ¤·¤Þ¤¹¡£
android.view.View ¤Ï¤³¤ì¤Þ¤Ç¤Ë¤â½Ð¤Æ¤¤Æ¤¤¤Þ¤¹¤¬¡¢²èÌ̾å¤Î¤¢¤ë¶ë·ÁÎΰè¤ÎÉÁ²è¤òôÅö¤¹¤ë¥¯¥é¥¹¤Ç¤¹¡£²èÌ̤ΰìÉô¤Ç¤¢¤ë¤³¤È¤â¤¢¤ì¤Ð¡¢²èÌÌÁ´ÂΤòɽ¤¹¤³¤È¤â¤¢¤ê¤Þ¤¹¡£
¤³¤ì¤ËÂФ·¤Æ android.view.ViewGroup ¤Ï¡¢Â¾¤Î View ¤ä ViewGroup ¤ò´ÉÍý¤·¡¢²èÌ̾å¤Ë¤É¤ÎÍͤ˥쥤¥¢¥¦¥È¤¹¤ë¤«¤ò·è¤á¤ë¤¿¤á¤Î¥¯¥é¥¹¤Ç¤¹¡£Android SDK ¤Ç¤Ï¡¢¤³¤Î ViewGroup ¤ò·Ñ¾µ¤·¤Æºî¤é¤ì¤¿ÍÍ¡¹¤Ê¥ì¥¤¥¢¥¦¥È´ÉÍýÍѤΥ¯¥é¥¹¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
º£¸å¤Î¥µ¥ó¥×¥ë¤òºîÀ®¤¹¤ë¤ËºÝ¤·¡¢¥ì¥¤¥¢¥¦¥È´ÉÍýÍÑ¥¯¥é¥¹¤ò»È¤Ã¤Æ¼«ºî View ¤ä UI ÉôÉʤòÇÛÃÖ¤·¤¿¤¤¤È»×¤¦¤³¤È¤¬¤¢¤ë¤À¤í¤¦¤È¤¤¤¦¤³¤È¤â¤¢¤ê¡¢¤³¤³¤Ç¤Ï ViewGroup ¤ò·Ñ¾µ¤·¤Æ¤¤¤ë¥¯¥é¥¹¤ÎÃæ¤Ç¤â¡¢android.widget ¥Ñ¥Ã¥±¡¼¥¸Æâ¤Î XXXXLayout ¤È¤¤¤¦Ì¾Á°¤Î¥ì¥¤¥¢¥¦¥È´ÉÍýÍÑ¥¯¥é¥¹¤Ë¤Ä¤¤¤Æ¾Ò²ð¤·¤¿¤¤¤È»×¤¤¤Þ¤¹¡£
deprecated »ØÄꤵ¤ì¤Æ¤¤¤ë¥¯¥é¥¹¤ÏµºÜ¤·¤Þ¤»¤ó¡£
¡û FrameLayout
android.widget.FrameLayout ¤Ï¡¢ºÇ¤âñ½ã¤Ê¥ì¥¤¥¢¥¦¥È¥¯¥é¥¹¤Ç¤¹¡£»Ò¤Ë»ØÄꤷ¤¿ View ¤Ï¡¢¤½¤Îº¸¾å³Ñ¤¬²èÌ̤κ¸¾å³Ñ¤È°ìÃפ¹¤ëÍͤËÇÛÃÖ¤µ¤ì¤Þ¤¹¡£°ÌÃÖ¤ò»ØÄꤹ¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£¤è¤Ã¤Æ¡¢Ê£¿ô¤Î View ¤ò»Ò¤Ë»ØÄꤷ¤¿¾ì¹ç¤Ï¡¢¸å¤ËÄɲä·¤¿ View ¤¬Á°¤Î View ¤ò¾å½ñ¤¤¹¤ë·Á¤Ë¤Ê¤ê¤Þ¤¹¡£
¢¤¬QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô¤·¤¿ FrameLayout ¤Î²èÌÌ¥µ¥ó¥×¥ë¤Ç¤¹¡£ÎФζë·Á¤Ë±£¤ì¤Æ¸«¤¨¤Þ¤»¤ó¤¬¡¢ÀĤ¤Êý¤Î¶ë·Á¤Ë¤Ï "This is the 1st child view." ¤È½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡£
¢¤¬¥ì¥¤¥¢¥¦¥ÈÄêµÁ¥Õ¥¡¥¤¥ë¤Ç¤¹¡£
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="This is the 1st child view." android:background="#0000ff" android:textColor="#ffffff"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This is the\n2nd child view." android:background="#00ff00" android:textColor="#000000"/> </FrameLayout>
- FrameLayout
- TextView
- TextView
¢¬¤ÎÍͤʹ½Â¤¤Ç¤¹¡£
FrameLayout ¤Ï¡¢android:layout_width/layout_height ¤¬ "fill_parent" ¤Î¤¿¤á¡¢¿ÆÁ´ÂΤ˹¤¬¤ê¤Þ¤¹¡£Á´¤Æ¤Î»ÒÍ×ÁǤκ¸¾å³Ñ¤¬Æ±¤¸°ÌÃ֤ˤʤ뤿¤á¡¢ÆóÈÖÌܤΠTextView ¤¬°ìÈÖÌܤΠTextView ¤ò¾å½ñ¤¤¹¤ëÍͤËÇÛÃÖ¤µ¤ì¤ë¤³¤È¤¬Ê¬¤«¤ë¤È»×¤¤¤Þ¤¹¡£
ºÇ½é¤Î TextView ¤Ï¡¢android:background="#0000ff" ¤ª¤è¤Ó android:textColor="#ffffff" ¤Ë¤è¤ê¡¢Çطʤ¬ÀĤÇʸ»ú¤¬Çò¤È¤Ê¤ê¤Þ¤¹¡£
¼¡¤Î TextView ¤Ï¡¢android:layout_width/layout_height ¤¬ "wrap_content" ¤Î¤¿¤á¡¢É½¼¨ÆâÍƤǤ¢¤ë "This is the \n2nd child view." ¤È¤¤¤¦Ê¸»úÎó¤ò°Ï¤àÂ礤µ¤È¤Ê¤ê¤Þ¤¹¡£¤Þ¤¿¡¢android:background="#00ff00" ¤Î¤¿¤áÇطʤÏÎФǤ¹¡Êʸ»ú¤Ï"#000000"¤Ç¹õ¡Ë¡£
¡û GridLayout
android.widget.GridLayout ¤Ï¡¢³Ê»Ò¾ó¤Ë View ¤òÇÛÃÖ¤·¤Þ¤¹¡£¤Þ¤º¡¢½Ä²£?x?¤Î³Ê»Ò¤È¤¹¤ë¤«¤ò GridLayout ¤Ë»ØÄꤷ¡¢ÇÛÃÖ¤¹¤ë»ÒÍ×ÁǤËÂФ·¤Æ¤É¤Î³Ê»Ò¤ËŽ¤ê¤Ä¤±¤ë¤«¹ÔÈÖ¹æ¤ÈÎóÈÖ¹æ¤ò»ØÄꤷ¤Þ¤¹¡£Î㤨¤Ð3x3¤Î³Ê»Ò¤Î¾ì¹ç¡¢¹ÔÎóÈÖ¹æ¤Ï²¼µ¤ÎÍͤˤʤê¤Þ¤¹¡£
(0,0) | (0,1) | (0,2) |
(1.0) | (1,1) | (1,2) |
(2,0) | (2,1) | (2,2) |
»ÒÍ×ÁǤϡ¢¤½¤ì¤¾¤ì¤Î³Ê»Ò¤ËŽ¤êÉÕ¤±¤ë¤³¤È¤â½ÐÍè¤ì¤Ð¡¢¹Ô¤¢¤ë¤¤¤ÏÎóÊý¸þ¤ËÊ£¿ô¤Î³Ê»Ò¤Ë¤Þ¤¿¤¬¤Ã¤ÆŽ¤êÉÕ¤±¤ë¤³¤È¤â½ÐÍè¤Þ¤¹¡£
- GridLayout ¥µ¥ó¥×¥ë1(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô)
¢¤¬¥ì¥¤¥¢¥¦¥ÈÄêµÁ¥Õ¥¡¥¤¥ë¤Ç¤¹¡£
<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#000000" android:columnCount="3" android:rowCount="3"> <TextView android:text="(0,0)" android:background="#ff0000" android:textColor="#000000" android:layout_column="0" android:layout_row="0"/> <TextView android:text="(0,1)" android:background="#00ff00" android:textColor="#000000" android:layout_column="1" android:layout_row="0"/> <TextView android:text="(0,2)" android:background="#0000ff" android:textColor="#ffffff" android:layout_column="2" android:layout_row="0" android:layout_rowSpan="2" android:layout_gravity="fill"/> <TextView android:text="(1,0)" android:background="#00ffff" android:textColor="#000000" android:layout_column="0" android:layout_columnSpan="2" android:layout_row="1" android:layout_gravity="fill"/> <TextView android:text="(2,0)" android:background="#ffff00" android:textColor="#000000" android:layout_column="0" android:layout_row="2"/> <TextView android:text="(2,1)" android:background="#ff00ff" android:textColor="#000000" android:layout_column="1" android:layout_columnSpan="2" android:layout_row="2" android:layout_gravity="fill"/> </GridLayout>
GridLayout ¤Î android:columnCount ¤ª¤è¤Ó android:rowCount ¤Ç¡¢?x? ¤Î³Ê»Ò¤Ë¤¹¤ë¤«ÀßÄꤷ¤Þ¤¹¡£¤³¤³¤Ç¤Ï 3x3 ¤È¤·¤Þ¤·¤¿¡£»ÒÍ×ÁǤΠTextView ¤Ë¤Ï¡¢android:layout_column ¤ª¤è¤Ó android:layout_row ¤Ë¤è¤ê¤É¤ÎÎ󡢤ɤιԤËÇÛÃÖ¤¹¤ë¤«¤òÀßÄꤷ¤Þ¤¹(0¤«¤é)¡£
(0,2) ¤Î TextView ¤Ï¹ÔÊý¸þ¤Ë 2 ³Ê»Ò¤Ë¤Þ¤¿¤¬¤é¤»¤ë¤¿¤á¤Ë android:layout_rowSpan ¤ò 2 ¤ËÀßÄꤷ¤Æ¤¤¤Þ¤¹¡£(1,0)¡¢(2,1) ¤Î TextView ¤ÏÎóÊý¸þ¤Ë 2 ³Ê»Ò¤Ë¤Þ¤¿¤¬¤é¤»¤ë¤¿¤á¤Ë¡¢android:layout_columnSpan ¤ò 2 ¤ËÀßÄꤷ¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤é¤Î TextView ¤Ï android:layout_gravity ¤ò "fill" ¤È¤·¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤¬Ìµ¤¤¤È¡¢ÇÛÃÖ¤Ï 2 ³Ê»Ò¤Ë¤Þ¤¿¤¬¤Ã¤Æ¤¤¤ë¤Î¤Ë 1 ³Ê»Òʬ¤·¤«Åɤê¤Ä¤Ö¤µ¤ì¤Ê¤«¤Ã¤¿¤¿¤á¤Ç¤¹¡£
- GridLayout ¥µ¥ó¥×¥ë2(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô)
¢¤¬¥ì¥¤¥¢¥¦¥ÈÄêµÁ¥Õ¥¡¥¤¥ë¤Ç¤¹¡£
<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" android:columnCount="3" android:rowCount="3"> <TextView android:text="(0,0)" android:background="#ff0000" android:textColor="#000000" android:layout_column="0" android:layout_row="0"/> <TextView android:text="(0,1)" android:background="#00ff00" android:textColor="#000000" android:layout_column="1" android:layout_row="0"/> <TextView android:text="(0,2)" android:background="#0000ff" android:textColor="#ffffff" android:layout_column="2" android:layout_row="0" android:layout_rowSpan="2" android:layout_gravity="fill"/> <TextView android:text="(1,0)" android:background="#00ffff" android:textColor="#000000" android:layout_column="0" android:layout_columnSpan="2" android:layout_row="1" android:layout_gravity="fill"/> <TextView android:text="(2,0)" android:background="#ffff00" android:textColor="#000000" android:layout_column="0" android:layout_row="2"/> <TextView android:text="(2,1)" android:background="#ff00ff" android:textColor="#000000" android:layout_column="1" android:layout_columnSpan="2" android:layout_row="2" android:layout_gravity="fill"/> </GridLayout>
ÀèÄø¤ÎÎ㤫¤é¡¢GridLayout ¤Î android:layout_width ¤ª¤è¤Ó android:layout_height ¤ò "wrap_content" ¤«¤é "fill_parent" ¤ËÊѤ¨¤¿¤À¤±¤Ç¤¹¡£(0,2)¤È(2,1) ¤Î³Ê»Ò¤¬²èÌ̤òÅɤê¤Ä¤Ö¤¹¤Þ¤Ç±ä¤Ð¤µ¤ì¤Æ¤¤¤ë¤Î¤¬Ê¬¤«¤ê¤Þ¤¹¡£
¡û LinearLayout
android.widget.LinearLayout ¤Ï¡¢¿åÊ¿¤¢¤ë¤¤¤Ï¿âľÊý¸þ¤Ë View ¤òÇÛÃÖ¤·¤Þ¤¹¡£
- LinearLayout ¿åÊ¿Êý¸þ¥µ¥ó¥×¥ë1(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:background="#000000"> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="1st view." android:background="#ff0000" android:textColor="#000000"/> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="2nd view." android:background="#00ff00" android:textColor="#000000"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="3rd view." android:background="#0000ff" android:textColor="#ffffff"/> </LinearLayout>
LinearLayout ¤Î android:orientation ¤ò "horizontal" ¤Ë¤¹¤ë¤³¤È¤Ç¡¢¿åÊ¿Êý¸þ¤Ë View ¤òÇÛÃÖ¤·¤Þ¤¹¡£TextView ¤Î android:layout_width ¤ÏÁ´¤Æ "wrap_content" ¤Î¤¿¤á¡¢Ê¸»úÎó¤ÎÉý¤ÈƱ¤¸Éý¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤Þ¤¿¡¢android:layout_height ¤ÏºÇ¸å¤Î TextView ¤Î¤ß "wrap_content" ¤Î¤¿¤á¡¢Ê¸»úÎó¤Î¹â¤µ¤ÈƱ¤¸¹â¤µ¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
- LinearLayout ¿åÊ¿Êý¸þ¥µ¥ó¥×¥ë2(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:background="#000000"> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="1st view." android:background="#ff0000" android:textColor="#000000"/> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:text="2nd view." android:background="#00ff00" android:textColor="#000000"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="3rd view." android:background="#0000ff" android:textColor="#ffffff"/> </LinearLayout>
¿åÊ¿Êý¸þ¥µ¥ó¥×¥ë1 ¤È°ã¤¦¤Î¤Ï¡¢ÆóÈÖÌܤΠTextView ¤Ë android:layout_weight="1" ¤È»ØÄꤷ¤Æ¤¤¤ëÅÀ¤Ç¤¹¡£weight ¤ò "1" ¤È¤¹¤ë¤³¤È¤Ç¡¢²èÌ̤Ë;Çò¤¬¤¢¤ë¾ì¹ç¤Ï¤½¤ì¤òËä¤á¤ëÍͤËÇÛÃÖ¤µ¤ì¤Þ¤¹¡£ÆóÈÖÌܤΠTextView¡ÊÎп§¡Ë¤¬¿åÊ¿Êý¸þ¥µ¥ó¥×¥ë1 ¤è¤ê¤â¿¤Ó¤Æ¤¤¤ë¤³¤È¤¬Ê¬¤«¤ë¤È»×¤¤¤Þ¤¹¡£
- LinearLayout ¿âľÊý¸þ¥µ¥ó¥×¥ë1(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#000000"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is the 1st child view." android:background="#ff0000" android:textColor="#000000"/> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is the\n2nd child view." android:background="#00ff00" android:textColor="#000000"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This is the 3rd child view." android:background="#0000ff" android:textColor="#ffffff"/> </LinearLayout>
LinearLayout ¤Î android:orientation ¤ò "vertical" ¤Ë¤¹¤ë¤³¤È¤Ç¡¢¿âľÊý¸þ¤Ë View ¤òÇÛÃÖ¤·¤Þ¤¹¡£Êý¸þ¤¬°ã¤¦ÅÀ°Ê³°¤Ï¡¢¿åÊ¿Êý¸þ¥µ¥ó¥×¥ë1 ¤ÈƱ¤¸ÍͤÊÇÛÃ֤Ȥʤê¤Þ¤¹¡£
- LinearLayout ¿âľÊý¸þ¥µ¥ó¥×¥ë2(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#000000"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is the 1st child view." android:background="#ff0000" android:textColor="#000000"/> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="This is the\n2nd child view." android:background="#00ff00" android:textColor="#000000"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This is the 3rd child view." android:background="#0000ff" android:textColor="#ffffff"/> </LinearLayout>
ÆóÈÖÌܤΠTextView ¤Ë android:layout_weight="1" ¤È»ØÄꤷ¤Æ¤¤¤ë°Ê³°¤Ï¡¢¿âľÊý¸þ¥µ¥ó¥×¥ë1 ¤ÈƱ¤¸¤Ç¤¹¡£ÆóÈÖÌܤΠTextView¡ÊÎп§¡Ë¤¬¿âľ¥µ¥ó¥×¥ë1 ¤è¤ê¤â¿¤Ó¤Æ¤¤¤ë¤³¤È¤¬Ê¬¤«¤ë¤È»×¤¤¤Þ¤¹¡£
¡û RelativeLayout
RelativeLayout ¤Ï¡¢¤¢¤ë View ¤ÎÇÛÃÖ¤ò»ØÄꤹ¤ëºÝ¤Ë¡¢Â¾¤Î View ¤ËÂФ¹¤ëÁêÂлØÄê¤Ë¤è¤Ã¤ÆÇÛÃÖ¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¸ß¤¤¤Ë»²¾È¤¹¤ë¤¿¤á¡¢³Æ View ¤Ë id ¤òÉÕ¤±¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¢QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000"> <TextView android:id="@+id/view1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="30px" android:layout_marginBottom="10px" android:text="This is the 1st view." android:background="#ff0000" android:textColor="#000000"/> <TextView android:id="@+id/view2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/view1" android:layout_alignParentRight="true" android:layout_marginLeft="10px" android:text="This is the 2nd view." android:background="#00ff00" android:textColor="#000000"/> <TextView android:id="@+id/view3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/view1" android:layout_toLeftOf="@id/view2" android:text="3rd view." android:background="#0000ff" android:textColor="#ffffff"/> <TextView android:id="@+id/view4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/view2" android:layout_centerHorizontal="true" android:layout_marginTop="10px" android:text="This is the 4th view." android:background="#00ffff" android:textColor="#000000"/> </RelativeLayout>
Á´¤Æ¤Î TextView ¤Ë id ¤òÉÕ¤±¤ë¤³¤È¤Ç¡¢id ¤Ë¤è¤ë»²¾È¤ò²Äǽ¤È¤·¤Æ¤¤¤Þ¤¹¡£
"view1" ¤ÏÉáÄ̤˲èÌ̾åÉô¤ËÇÛÃÖ¤·¤Þ¤¹¡£layout_height="wrap_content" ¤Ë¤è¤ê¡¢Ê¸»úÎó¤ÈƱ¤¸¤Î¹â¤µ¤òÀê¤á¤Þ¤¹¡£android:layout_marginTop/layout_marginBottom ¤Ë¤è¤ê¡¢¾å²¼¤Ë 10px ¤º¤Ä¤Î¥Þ¡¼¥¸¥ó¤òÀßÄꤷ¤Æ¤¤¤Þ¤¹¡£
"view2" ¤Ï¡¢android:layout_below="@id/view1" ¤Ë¤è¤ê view1 ¤Î²¼¤ËÇÛÃÖ¤·¤Þ¤¹¡£¤«¤Ä¡¢android:layout_alignParentRight="true" ¤Ë¤è¤ê¿Æ(RelativeLayout) ¤Î±¦Ã¼¤Ë·¤¦ÍͤËÇÛÃÖ¤µ¤ì¤Þ¤¹¡£
"view3" ¤Ï¡¢android:layout_below="@id/view1" ¤ª¤è¤Ó android:layout_toLeftOf="@id/view2" ¤Ë¤è¤ê¡¢view1 ¤Î²¼¤Ç¤«¤Ä view2 ¤Îº¸¤ËÇÛÃÖ¤µ¤ì¤Þ¤¹¡£
"view4" ¤Ï¡¢android:layout_below="@id/view2" ¤Ë¤è¤ê¡¢view2 ¤Î²¼¤ËÇÛÃÖ¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢android:layout_centerHorizontal="true" ¤Ë¤è¤ê¡¢¿åÊ¿Êý¸þ¤Î¿¿¤óÃæ¤ËÇÛÃÖ¤µ¤ì¤Þ¤¹¡£
¾¤Ë¤â»È¤¨¤ëÇÛÃÖ»ØÄ꤬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢API¥É¥¥å¥á¥ó¥È¤ò³Îǧ¤·¤Æ¤ß¤Æ²¼¤µ¤¤¡£
¡û TableLayout
TableLayout ¤Ï¡¢View ¤ò¥Æ¡¼¥Ö¥ë¾õ¤ËÇÛÃÖ¤·¤Þ¤¹¡£
- TableLayout ¥µ¥ó¥×¥ë1(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô¡Ë
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000"> <TableRow> <TextView android:text="This is the (1,1) view." android:background="#ff0000" android:padding="5px" android:textColor="#000000"/> <TextView android:text="This is the (1,2) view." android:background="#00ff00" android:padding="5px" android:textColor="#000000"/> </TableRow> <TableRow> <TextView android:text="This is the (2,1) view." android:background="#0000ff" android:textColor="#ffffff" android:padding="5px"/> <TextView android:text="This is the (2,2) view." android:background="#00ffff" android:padding="5px" android:textColor="#000000"/> </TableRow> <TableRow> <TextView android:text="This is the (3,1) view." android:background="#ffff00" android:padding="5px" android:textColor="#000000"/> <TextView android:text="This is the (3,2) view." android:background="#ff00ff" android:padding="5px" android:textColor="#000000"/> </TableRow> </TableLayout>
°ì¹Ô¤òɽ¤¹ <TableRow></TableRow> ¤Î´Ö¤Ë¡¢¤½¤Î¹Ô¤Ëʤ٤ë TextView ¤òµ½Ò¤·¤Þ¤¹¡£³Æ TextView ¤Ë android:padding="5px" ¤ò»ØÄꤷ¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤ì¤¬Ìµ¤¤¾ì¹ç¤Ï³Æ TextView ¤Îʸ»ú¼þ¤ê¤Î;Çò¤¬Ìµ¤¯¤Ê¤ê¤Þ¤¹¡£¿åÊ¿Êý¸þ¤Ë¹¤¬¤ê¤¤é¤º¤ËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¤Î¤¬Ê¬¤«¤ë¤È»×¤¤¤Þ¤¹¤¬¡¢¤³¤ì¤Ï¥µ¥ó¥×¥ë2 ¤Ç²ò·è¤·¤Æ¤¤¤Þ¤¹¡£
- TableLayout ¥µ¥ó¥×¥ë2(QVGA(320x480:mdpi)¥¨¥ß¥å¥ì¡¼¥¿¤Ç¼Â¹Ô)
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1" android:background="#000000"> <TableRow> <TextView android:text="This is the (1,1) view." android:background="#ff0000" android:padding="5px" android:textColor="#000000"/> <TextView android:text="This is the (1,2) view." android:background="#00ff00" android:padding="5px" android:textColor="#000000"/> </TableRow> <TableRow> <TextView android:text="This is the (2,1) view." android:background="#0000ff" android:textColor="#ffffff" android:padding="5px"/> <TextView android:text="This is the (2,2) view." android:background="#00ffff" android:padding="5px" android:textColor="#000000"/> </TableRow> <TableRow> <TextView android:text="This is the (3,1) view." android:background="#ffff00" android:padding="5px" android:textColor="#000000"/> <TextView android:text="This is the (3,2) view." android:background="#ff00ff" android:padding="5px" android:textColor="#000000"/> </TableRow> </TableLayout>
¥µ¥ó¥×¥ë1 ¤È°ã¤Ã¤Æ¡¢¿åÊ¿Êý¸þ¤Ë¹¤¬¤ê¤¤Ã¤ÆÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¤³¤È¤¬Ê¬¤«¤ë¤È»×¤¤¤Þ¤¹¡£TableLayout ¤Ë android:stretchColumns="1" ¤ò»ØÄꤹ¤ë¤³¤È¤Ç¡¢²èÌ̤Î;Çò¤¬Ìµ¤¤Íͤ˳ÆÎó¤¬ÇÛÃÖ¤µ¤ì¤Þ¤¹¡£