便å©ãªéçºãã¼ã«ï¼ã¬ã¤ã¢ã¦ããæé©åãã layoutopt (Android Developers - Dev Guideå訳)
åæã¯こちらã
æ¦è¦
layoutoptã¯ãã¢ããªã±ã¼ã·ã§ã³ã®ã¬ã¤ã¢ã¦ãã¨ã¬ã¤ã¢ã¦ããã¨ã©ã«ãã¼ãæé©åããããã®ãã¼ã«ã§ããã¬ã¤ã¢ã¦ããã¡ã¤ã«ããªã½ã¼ã¹ãã¡ã¤ã«ãåå ã¨ãããã¢ããªã±ã¼ã·ã§ã³ã®ããã©ã¼ãã³ã¹ã«å½±é¿ãåã¼ãéå¹çãªããããã¯ãã®ä»ã®ã¿ã¤ãã®åé¡ãç´ æ©ããã§ãã¯ãããã¨ãã§ãã¾ãã
ãã¼ã«ãå®è¡ããã«ã¯ãã¿ã¼ããã«ãéã㦠SDKã®tools/ãã£ã¬ã¯ããªãã layout <ãªã½ã¼ã¹å> ãèµ·åãã¾ããã³ãã³ãå¼æ°ã«ã¯ã解æãããæªã³ã³ãã¤ã«ã®ãªã½ã¼ã¹XMLãã¡ã¤ã«ããã£ã¬ã¯ããªãæå®ãã¾ãã
å®è¡æã«ãã¼ã«ã¯æå®ã®XMLãã¡ã¤ã«ãèªã¿è¾¼ã¿ãäºåã«å®ç¾©ãããã«ã¼ã«ã»ããã«å¾ã£ã¦ã¬ã¤ã¢ã¦ãã®æ§é ã解æãã¾ããåé¡ãçºè¦ããå ´åã¯ãåé¡ããã¡ã¤ã«åãè¡çªå·ãåé¡ã®æ¦è¦ã«é¢ããæ å ±ã¨å ±ã«ãæ¨å®ããã解決æ¹æ³ã®ããã¤ããåºåãã¾ãã
使ãæ¹
lyaoutopt ãå®è¡ããã«ã¯ãå¼æ°ã«ã¬ã¤ã¢ã¦ããªã½ã¼ã¹ã®ãªã¹ãï¼ã¹ãã¼ã¹åºåãã§è¤æ°å¯ï¼ãæå®ãã¾ãï¼
layoutopt <XMLãã¡ã¤ã«ã®ãªã¹ã ã¾ã㯠ãã£ã¬ã¯ããª>
ä¾ï¼
$ layoutopt res/layout-land $ layoutopt res/layout/main.xml res/layout-land/main.xml
å®è¡çµæã®ä¾
$ layoutopt samples/ samples/compound.xml 7:23 The root-level <FrameLayout/> can be replaced with <merge/> 11:21 This LinearLayout layout or its FrameLayout parent is useless samples/simple.xml 7:7 The root-level <FrameLayout/> can be replaced with <merge/> samples/too_deep.xml -1:-1 This layout has too many nested layouts: 13 levels, it should have <= 10! 20:81 This LinearLayout layout or its LinearLayout parent is useless 24:79 This LinearLayout layout or its LinearLayout parent is useless 28:77 This LinearLayout layout or its LinearLayout parent is useless 32:75 This LinearLayout layout or its LinearLayout parent is useless 36:73 This LinearLayout layout or its LinearLayout parent is useless 40:71 This LinearLayout layout or its LinearLayout parent is useless 44:69 This LinearLayout layout or its LinearLayout parent is useless 48:67 This LinearLayout layout or its LinearLayout parent is useless 52:65 This LinearLayout layout or its LinearLayout parent is useless 56:63 This LinearLayout layout or its LinearLayout parent is useless samples/too_many.xml 7:413 The root-level <FrameLayout/> can be replaced with <merge/> -1:-1 This layout has too many views: 81 views, it should have <= 80! samples/useless.xml 7:19 The root-level <FrameLayout/> can be replaced with <merge/> 11:17 This LinearLayout layout or its FrameLayout parent is useless
å®è¡çµæã®èªã¿æ¹
å®è¡çµæã¯ä¸è¨ã®é ã§åºåããã¦ãã¾ãã
- 解æ対象ã®XMLãã¡ã¤ã«å
- éå§è¡çªå·ï¼çµäºè¡çªå·
- åé¡ã®å 容 ã¾ã㯠æé©åãããå 容
- 解決ã®ããã®ãã³ã
注æç¹
ã³ãã³ããå®è¡ãã¦ãããªã½ã¼ã¹ãã¡ã¤ã«ãèªåã§å¤æããããã¨ã¯ããã¾ãããããã¾ã§ã診æãã¼ã«ã§ãã
ã¾ã¨ã
Androidã¢ããªéçºè
ã¨ãã¦ãã¬ã¤ã¢ã¦ãã®è¤éåã«ä¼´ãããã©ã¼ãã³ã¹ã®ä½ä¸ã«ã¯é¢å¿ãæããããå¾ãªãã®ã§è©¦ãã¦ã¿ã¾ããããç¹ã«è¤éãªã¬ã¤ã¢ã¦ããæã¤ã¢ããªã±ã¼ã·ã§ã³ã«å¯¾ãã¦ä½¿ã£ã¦ã¿ã価å¤ãããã¨æãã¾ããã
ã¾ããå®è¡çµæã®ä¾ã§ã¯ãã¬ã¤ã¢ã¦ãã®ã¿ã°ãç½®ãæãããã¦ãããã使ããã¦ããªãã¬ã¤ã¢ã¦ããææããã¦ãããã¨ã¯å®¹æã«æ³åã§ããã®ã§ãããä½æ°ã«ãã¹ãã§ããã¬ã¤ã¢ã¦ãã®ã¬ãã«ã¯10ã¾ã§ã§ãã£ãããã¬ã¤ã¢ã¦ããä¿æã§ãããã¥ã¼ã®æ°ã80ã¾ã§ã§ãããã¨ãè¨è¼ããã¦ããããã¦ãè¯ãåå¼·ã«ãªãã¾ããã
æ責ï¼æè¡é¨ãç¬æ¸ ç´å(åã»æ¥æ¬Androidã®ä¼åå½æ¯é¨é·/æ å ±ã»ãã¥ãªãã£ã¹ãã·ã£ãªã¹ã)