Upgrade to Pro — share decks privately, control downloads, hide ads and more …

続・android:layout_weight を使うとアプリが重くなるのか?

続・android:layout_weight を使うとアプリが重くなるのか?

関西モバイルアプリ研究会 #18 発表枠のライトニングトークで使用したスライドです ⬇️
http://kanmoba.connpass.com/event/39869/

ViewGroup がネストしている状態で layout_weight を使用するとアプリが重くなります ⬇️
https://developer.android.com/training/improving-layouts/optimizing-layout.html

実機の Android 端末に対して Hierarchy Viewer を使って View の階層構造を調べる ⬇︎
http://vividcode.hatenablog.com/entry/android-app/tools/hierarchy-viewer

前回のスライド ⬇︎
「android:layout_weight を使うとアプリが重くなるのか?(ディレクターズ・カット版)」
https://speakerdeck.com/84d010m08/android-layout-weight-woshi-utoapurigazhong-kunarufalseka-deirekutazukatutoban

umeda.apk(大阪・梅田で開催されている Android の勉強会)⬇
http://shibuya-apk.connpass.com/

どんちゃん

September 28, 2016
Tweet

More Decks by どんちゃん

Other Decks in Programming

Transcript

  1. 
 ⚠ WARNING ⚠
 ※ umeda.apk #1 & #2 Ͱͷ

    LT ࢿྉ͕
 ਵॴͰ࢖͍ճ͞Ε͍ͯ·͢ 3
  2. ࣗݾ঺հ ڮ౓๎໻ʢ͸͠Ͳͱ΋΍ɺ1990 ೥ 7 ݄ 15 ೔ - ʣ 2014

    ೥Ҏ߱ɺ೥ؒͰϓϦΫϥΛࡱΔ
 ճ਺͕ࣗݾϕετΛߋ৽͠ଓ͚͍ͯ·͢ 
 ʢࠓ೥͸طʹ 4 ճࡱӨʣ ීஈΑ͘Ӿཡ͍ͯ͠ΔΞϓϦ͸
 ϑϦϡʔ ͷʮϐΫτϦϯΫʯͰ͢ 4
  3. Android Developers ʰϨΠΞ΢τ֊૚ͷ࠷దԽʱ https:// developer.android.com/ training/improving-layouts/ optimizing-layout.html “Furthermore, nesting several

    instances of LinearLayout that use the layout_weight parameter can be especially expensive as each child needs to be measured twice.” 8
  4. 2016 ೥ 6 ݄ 17 ೔ʢۚʣ umeda.apk #1 ʹͯ 5

    ෼ൃද࿮Ͱʮandroid:layout_weight Λ࢖͏ͱΞϓϦ͕ॏ͘ͳΔͷ͔ʁʯ
 ͱ͍͏ LT Λ͠·ͨ͠ LT ऴྃޙʮlayout_weight Ͱඳը ͕ॏ͘ͳΔͷ͸ ViewGroup ͕ωε τ͍ͯ͠Δ৔߹Ͱ͸ʁʯͱ͍͏ࢦఠΛ ड͚ͨͷͰ࠶ݕূͯ͠Έ·ͨ͠ ⌨ 9
  5. Hierarchy Viewer ͱ͸ʁ ϨΠΞ΢τඳըʹ͔͔Δ
 ࣌ؒΛදࣔͯ͘͠ΕΔ Android Device Monitor
 ͔Β࢖༻Մೳ ⭕

    ࣮୺຤Ͱ࢖༻͢Δʹ͸Ұखؒඞཁ http://vividcode.hatenablog.com/ entry/android-app/tools/ hierarchy-viewer 11
  6. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />


    
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight=“4”> 
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight=“2"> 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 </LinearLayout>
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 </LinearLayout>
 </LinearLayout> 5 Button 5 ౳෼ 3 ֊૚ωετ
 ιʔείʔυˍը໘ʢlayout_weightʣ 14
  7. Measure Layout Draw ߹ܭ 1 ճ໨ 0.045 ms 0.758 ms

    1.522 ms 2.325 ms 2 ճ໨ 0.045 ms 0.756 ms 1.479 ms 2.280 ms 3 ճ໨ 0.198 ms 1.125 ms 1.129 ms 2.452 ms 4 ճ໨ 0.045 ms 1.034 ms 2.242 ms 3.321 ms 5 ճ໨ 0.045 ms 1.042 ms 1.410 ms 2.497 ms ฏۉ 0.076 ms 0.943 ms 1.556 ms 2.575 ms 5 Button 5 ౳෼ 3 ֊૚ωετ
 ߹ܭ 97 views ܭଌ݁Ռʢlayout_weightʣ 15
  8. 6 Button 5 ౳෼ 3 ֊૚ωετ
 ιʔείʔυˍը໘ʢԣ෯Λ dp ࢦఆʣ <?xml

    version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 
 <LinearLayout
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 
 <LinearLayout
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 </LinearLayout>
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 
 <android.support.v7.widget.AppCompatButton
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 </LinearLayout>
 </LinearLayout> 16
  9. 6 Button 5 ౳෼ 3 ֊૚ωετ ߹ܭ 97 views ܭଌ݁Ռʢԣ෯Λ

    dp ࢦఆʣ Measure Layout Draw ߹ܭ 1 ճ໨ 0.042 ms 0.187 ms 1.476 ms 1.705 ms 2 ճ໨ 0.184 ms 0.345 ms 2.205 ms 2.734 ms 3 ճ໨ 0.048 ms 0.316 ms 1.539 ms 1.903 ms 4 ճ໨ 0.050 ms 0.400 ms 1.784 ms 2.234 ms 5 ճ໨ 0.049 ms 0.341 ms 1.514 ms 1.904 ms ฏۉ 0.075 ms 0.318 ms 1.704 ms 2.096 ms 17
  10. Button 5 ౳෼ 3 ֊૚ωετ
 ඳը଎౓·ͱΊʢAndroid 6.0ʣ ޡࠩͷൣғʢʁʣฏۉ஋Ͱ͸ͳ͘ 1 ճͷଌఆ஋Ͱ


    ൺֱ͢Δͱ݁Ռ͕มΘͬͯ͠·͏ ΤϛϡϨʔλͱ࣮୺຤ (Nexus 7) Ͱ ListView ΛεΫϩʔϧ ͤͯ͞Έͯ΋ҧ͍͕͋Δ͔͸ඍົͰ֬৴͕࣋ͯͳ͍ 0↕ layout_weight ԣ෯Λ dp ࢦఆ ߹ܭ࣌ؒͷฏۉ 2.575 ms 2.096 ms 18
  11. ࢼ͞ΕΔ API Ϩϕϧᶸ14ᶹ͜ͱ Android 4.0 (Ice Cream Sandwich) ʹͯ Button

    Λԣʹ 5 ౳෼ˍ 3 ֊૚ωετͨ͠
 ϨΠΞ΢τͷੜ੒࣌ؒΛܭଌ ⏱ 19
  12. 5 Button 5 ౳෼ 3 ֊૚ωετ
 ߹ܭ 97 views ܭଌ݁Ռʢlayout_weightʣ

    Measure Layout Draw ߹ܭ 1 ճ໨ 0.355 ms 34.715 ms 42.180 ms 77 .250 ms 2 ճ໨ 0.467 ms 29.938 ms 46.369 ms 76.774 ms 3 ճ໨ 0.538 ms 32.001 ms 33.804 ms 66.343 ms 4 ճ໨ 0.458 ms 32.929 ms 34.624 ms 68.011 ms 5 ճ໨ 0.488 ms 24.862 ms 37 .005 ms 62.355 ms ฏۉ 0.461 ms 30.889 ms 38.796 ms 70.147 ms 20
  13. 6 Button 5 ౳෼ 3 ֊૚ωετ ߹ܭ 97 views ܭଌ݁Ռʢԣ෯Λ

    dp ࢦఆʣ Measure Layout Draw ߹ܭ 1 ճ໨ 0.514 ms 7 .439 ms 34.270 ms 42.223 ms 2 ճ໨ 0.462 ms 6.731 ms 35.968 ms 43.161 ms 3 ճ໨ 0.573 ms 7 .092 ms 32.675 ms 40.340 ms 4 ճ໨ 0.375 ms 6.028 ms 45.829 ms 52.232 ms 5 ճ໨ 0.383 ms 8.479 ms 52.771 ms 61.633 ms ฏۉ 0.461 ms 7 .154 ms 40.303 ms 47 .918 ms 21
  14. Button 5 ౳෼ 3 ֊૚ωετ
 ඳը଎౓·ͱΊʢAndroid 4.0ʣ Android 4.0 Ͱܭଌ͢Δͱ෼͔Γ΍͍݁͢Ռ͕ग़ͨ

    ߹ܭ࣌ؒͷฏۉ஋Λൺֱ͢Δͱ໿ 20 ms ͷ͕ࠩ͋Δ ⏱ ΤϛϡϨʔλͱ࣮ػͰ ListView ΛεΫϩʔϧͤͨ͞ͱ͜Ζ ࣮ػͰ͸ layout_weight ͷํ͕͔ᷮʹॏ͍ؾ͕ͨ͠ 0↕ layout_weight ԣ෯Λ dp ࢦఆ ߹ܭ࣌ؒͷฏۉ 70.147 ms 47 .918 ms 22
  15. ᶃ Button 5 ౳෼ʢAndroid 4.0ʣ
 ViewGroup 1 ֊૚ͱ 3 ֊૚ͷൺֱ

    umeda.apk #1 ͷ LT εϥΠυ͔Β ViewGroup 1 ֊૚Ͱ Button Λ
 5 ౳෼ͨ͠ϨΠΞ΢τͷฏۉඳը࣌ؒΛࢀরʢ˞ಉ͡؀ڥͰܭଌʣ https://speakerdeck.com/84d010m08/android-layout-weight- woshi-utoapurigazhong-kunarufalseka-deirekutazukatutoban? slide=26 layout_weight ԣ෯Λ dp ࢦఆ ViewGroup 1 ֊૚ 53.108 ms 45.866 ms ViewGroup 3 ֊૚ 70.147 ms 47 .918 ms 23
  16. ᶄ Button 5 ౳෼ʢAndroid 4.0ʣ
 ViewGroup 1 ֊૚ͱ 3 ֊૚ͷൺֱ

    ViewGroup ͷωετ͕ਂ͘ͳͬͨͱ͖ͷඳը࣌ؒͷ૿Ճ཰͕
 ԣ෯ dp ࢦఆ ΑΓ layout_weight ͷํ͕ߴ͍͜ͱ͕෼͔Δ ωετͨ͠ LinearLayout ʹ layout_weight Λ࢖༻
 ͢Δͱࢠཁૉ͕ 2 ճଌఆ͞ΕΔʢެࣜυΩϡϝϯτΑΓʣ 24 ViewGroup 1 ˠ 3 ֊૚ͷඳը࣌ؒͷࠩ ԣ෯ dp ࢦఆ 2 ms ૿Ճ ↗ layout_weight 17 ms ૿Ճ ↗
  17. ૯·ͱΊ ViewGroup ͷωετঢ়گԼͰ layout_weight ʹ
 པΒ͟ΔΛಘͳ͘ͳͬͨ৔߹͸ ConstraintLayout ΍ PercentRelativeLayout ͷ࢖༻΋ݕ౼ͯ͠Έ·͠ΐ͏

    ϨΠΞ΢τͷඳը଎౓Λ্͛ΔͨΊʹ ViewGroup ͷ
 ωετ͕ઙ͍ˍγϯϓϧͳσβΠϯΛ໨ࢦ͠·͠ΐ͏ Hierarchy Viewer Λ࢖ͬͯϨΠΞ΢τඳը଎౓ͷ
 ϘτϧωοΫʹͳ͍ͬͯΔ෦෼Λ୳ͯ͠Έ·͠ΐ͏ 25
  18. <?xml version="1.0" encoding="utf-8"?>
 <android.support.percent.PercentRelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 
 <android.support.v7.widget.AppCompatButton


    android:id="@+id/button_1"
 android:layout_height="@dimen/height_button"
 app:layout_widthPercent="20%" />
 
 <android.support.percent.PercentRelativeLayout
 android:layout_height="wrap_content"
 android:layout_toRightOf="@id/button_1"
 app:layout_widthPercent="80%">
 
 <android.support.percent.PercentRelativeLayout
 android:id="@+id/nest_percentRelativeLayout"
 android:layout_height="wrap_content"
 app:layout_widthPercent="50%">
 
 <android.support.v7.widget.AppCompatButton
 android:id="@+id/button_2"
 android:layout_height="@dimen/height_button"
 app:layout_widthPercent="50%" />
 
 <android.support.v7.widget.AppCompatButton
 android:layout_height="@dimen/height_button"
 android:layout_toRightOf="@id/button_2"
 app:layout_widthPercent="50%" />
 </android.support.percent.PercentRelativeLayout>
 
 <android.support.v7.widget.AppCompatButton
 android:id="@+id/button_4"
 android:layout_height="@dimen/height_button"
 android:layout_toRightOf="@id/nest_percentRelativeLayout"
 app:layout_widthPercent="25%" />
 
 <android.support.v7.widget.AppCompatButton
 android:layout_height="@dimen/height_button"
 android:layout_toRightOf="@id/button_4"
 app:layout_widthPercent="25%" />
 </android.support.percent.PercentRelativeLayout>
 </android.support.percent.PercentRelativeLayout>
  19. : Button 5 ౳෼ 3 ֊૚ωετ ߹ܭ 97 views ܭଌ݁ՌʢPercentRelativeLayoutʣ

    Measure Layout Draw ߹ܭ 1 ճ໨ 0.769 ms 71.907 ms 37 .750 ms 110.426 ms 2 ճ໨ 0.349 ms 45.133 ms 35.810 ms 81.292 ms 3 ճ໨ 0.624 ms 42.601 ms 38.598 ms 81.823 ms 4 ճ໨ 0.637 ms 36.907 ms 38.468 ms 76.012 ms 5 ճ໨ 0.430 ms 37 .507 ms 35.436 ms 73.373 ms ฏۉ 0.562 ms 46.811 ms 37 .212 ms 84.585 ms 30
  20. Button 5 ౳෼ 3 ֊૚ωετ
 ඳը଎౓·ͱΊʢAndroid 4.0ʣ PercentRelativeLayout ͷඳը͕࣌ؒ࠷΋஗͍ͱ͍͏
 ݁Ռʹ

    ⏱ PercentRelativeLayout ͸ ViewGroup 1 ֊૚Ͱ৭ʑͳσ βΠϯ͕࠶ݱͰ͖ΔͷͰผʹେͨ͠໰୊Ͱ͸ͳ͍͔΋ layout_weight ԣ෯Λ dp ࢦఆ PercentRelative Layout ߹ܭ࣌ؒͷฏۉ 70.147 ms 47 .918 ms 84.585 ms 31
  21. 5 5 ֊૚ωετ (layout_weight) 
 ιʔείʔυˍը໘ <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout> 33
  22. Measure Layout Draw ߹ܭ 1 ճ໨ 0.043 ms 0.596 ms

    1.542 ms 2.181 ms 2 ճ໨ 0.044 ms 1.249 ms 2.178 ms 3.471 ms 3 ճ໨ 0.050 ms 0.708 ms 2.144 ms 2.902 ms 4 ճ໨ 0.053 ms 0.735 ms 2.378 ms 3.166 ms 5 ճ໨ 0.060 ms 0.648 ms 1.404 ms 2.112 ms ฏۉ 0.050 ms 0.787 ms 1.929 ms 2.766 ms 5 5 ֊૚ωετ (layout_weight)
 ܭଌ݁Ռ 119 views 34
  23. 6 5 ֊૚ωετ (PercentRelativeLayout)
 ιʔείʔυˍը૾ <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"


    android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <android.support.percent.PercentRelativeLayout
 xmlns:app="http://schemas.android.com/apk/res-auto"
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <Button
 android:id="@+id/split_5_1"
 android:layout_height="@dimen/height_button"
 android:scaleType="centerCrop"
 app:layout_widthPercent="20%" />
 <Button
 android:id="@+id/split_5_2"
 android:layout_height="@dimen/height_button"
 android:layout_toRightOf="@id/split_5_1"
 android:scaleType="centerCrop"
 app:layout_widthPercent="20%" />
 <Button
 android:id="@+id/split_5_3"
 android:layout_height="@dimen/height_button"
 android:layout_toRightOf="@id/split_5_2"
 android:scaleType="centerCrop"
 app:layout_widthPercent="20%" />
 <Button
 android:id="@+id/split_5_4"
 android:layout_height="@dimen/height_button"
 android:layout_toRightOf="@id/split_5_3"
 android:scaleType="centerCrop"
 app:layout_widthPercent="20%" />
 <Button
 android:id="@+id/split_5_5"
 android:layout_height="@dimen/height_button"
 android:layout_toRightOf="@id/split_5_4"
 android:scaleType="centerCrop"
 app:layout_widthPercent="20%" />
 </android.support.percent.PercentRelativeLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout> 35
  24. Measure Layout Draw ߹ܭ 1 ճ໨ 0.053 ms 0.672 ms

    2.710 ms 3.435 ms 2 ճ໨ 0.049 ms 0.746 ms 3.131 ms 3.926 ms 3 ճ໨ 0.093 ms 0.962 ms 1.880 ms 2.935 ms 4 ճ໨ 0.051 ms 0.811 ms 2.422 ms 3.284 ms 5 ճ໨ 0.239 ms 0.614 ms 1.527 ms 2.380 ms ฏۉ 0.097 ms 0.761 ms 2.334 ms 3.192 ms 6 5 ֊૚ωετ (PercentRelativeLayout)
 ܭଌ݁Ռ 119 views 36
  25. : 5 ֊૚ωετ (ԣ෯Λ dp ࢦఆ)
 ιʔείʔυˍը໘ <?xml version="1.0" encoding="utf-8"?>


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal">
 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <Button
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 <Button
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 <Button
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 <Button
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 <Button
 android:layout_width="@dimen/size_5_split"
 android:layout_height="@dimen/height_button" />
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout> 37
  26. Measure Layout Draw ߹ܭ 1 ճ໨ 0.049 ms 0.264 ms

    2.388 ms 2.701 ms 2 ճ໨ 0.042 ms 0.300 ms 2.328 ms 2.670 ms 3 ճ໨ 0.042 ms 0.329 ms 2.749 ms 3.120 ms 4 ճ໨ 0.049 ms 0.406 ms 2.272 ms 2.727 ms 5 ճ໨ 0.044 ms 0.242 ms 2.187 ms 2.473 ms ฏۉ 0.045 ms 0.308 ms 2.385 ms 2.738 ms : 5 ֊૚ωετ (ԣ෯Λ dp ࢦఆ)
 ܭଌ݁Ռ 119 views 38
  27. 5 ֊૚ωετඳը࣌ؒ
 ·ͱΊʢAndroid 6.0ʣ ޡࠩͷൣғʢʁʣ
 1 ճͷଌఆ஋Ͱൺֱ͢Δͱ݁Ռ͕มΘͬͯ͠·͏ ΤϛϡϨʔλͱ࣮୺຤ (Nexus 7)

    ͰεΫϩʔϧͤͯ͞Έͨ
 ͱ͜Ζɺҧ͍͕͋Δ͔͸ඍົͰ֬৴͕࣋ͯͳ͍ 0↕ layout_weight PercentRelative
 Layout ԣ෯Λ dp ࢦఆ ߹ܭ࣌ؒͷฏۉ 2.766 ms 3.192 ms 2.738 ms 39
  28. 5 5 ౳෼Λݸʑʹ 5 ֊૚ωετ (layout_weight) ιʔείʔυˍը໘ <?xml version="1.0" encoding="utf-8"?>


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 android:layout_height="wrap_content">
 <LinearLayout
 android:layout_weight="1"
 android:layout_width="0dp"
 41
  29. Measure Layout Draw ߹ܭ 1 ճ໨ 0.182 ms 1.452 ms

    3.140 ms 4.774 ms 2 ճ໨ 0.049 ms 1.410 ms 2.625 ms 4.084 ms 3 ճ໨ 0.183 ms 1.684 ms 2.743 ms 4.610 ms 4 ճ໨ 0.047 ms 1.634 ms 2.250 ms 3.931 ms 5 ճ໨ 0.047 ms 1.301 ms 2.250 ms 3.598 ms ฏۉ 0.102 ms 1.496 ms 2.602 ms 4.199 ms 5 5 ౳෼Λݸʑʹ 5 ֊૚ωετ (layout_weight) ܭଌ݁Ռ 295 views 42
  30. Measure Layout Draw ߹ܭ 1 ճ໨ 0.045 ms 0.751 ms

    2.399 ms 3.195 ms 2 ճ໨ 0.044 ms 1.032 ms 2.196 ms 3.272 ms 3 ճ໨ 0.041 ms 1.053 ms 1.396 ms 2.490 ms 4 ճ໨ 0.044 ms 0.992 ms 2.244 ms 3.280 ms 5 ճ໨ 0.045 ms 1.045 ms 2.763 ms 3.853 ms ฏۉ 0.044 ms 0.975 ms 2.200 ms 3.218 ms 6 5 ౳෼Λݸʑʹ 5 ֊૚ωετ
 (PercentRelativeLayout) ܭଌ݁Ռ 295 views 43
  31. Measure Layout Draw ߹ܭ 1 ճ໨ 0.046 ms 0.472 ms

    2.060 ms 2.578 ms 2 ճ໨ 0.045 ms 0.555 ms 2.142 ms 2.742 ms 3 ճ໨ 0.044 ms 0.519 ms 2.321 ms 2.884 ms 4 ճ໨ 0.047 ms 0.906 ms 2.623 ms 3.576 ms 5 ճ໨ 0.062 ms 0.502 ms 1.964 ms 2.528 ms ฏۉ 0.049 ms 0.591 ms 2.222 ms 2.862 ms : 5 ౳෼Λݸʑʹ 5 ֊૚ωετ
 (ԣ෯Λ dp ࢦఆ) ܭଌ݁Ռ 295 views 44
  32. 5 ౳෼Λݸʑʹ 5 ֊૚ωετ ·ͱΊʢAndroid 6.0ʣ ޡࠩͷൣғʢʁʣ
 1 ճͷଌఆ஋Ͱൺֱ͢Δͱ݁Ռ͕มΘͬͯ͠·͏ ΤϛϡϨʔλͱ࣮୺຤

    (Nexus 7) ͰεΫϩʔϧͤͯ͞Έͨ
 ͱ͜Ζɺҧ͍͕͋Δ͔͸ඍົͰ֬৴͕࣋ͯͳ͍ 0↕ layout_weight PercentRelative
 Layout ԣ෯Λ dp ࢦఆ ߹ܭ࣌ؒͷฏۉ 4.199 ms 3.218 ms 2.862 ms 45
  33. 5 ౳෼Λݸʑʹ 5 ֊૚ωετ
 ·ͱΊʢAndroid 6.0ʣ layout_weight=“1” ͸ઃఆͰ͖Δͱ͜Ζશͯʹઃ ఆ͠·ͨ͠ʢ25 ݸʣ

    Ռͨͯ͠ൺֱ͢Δ৚݅ͱͯ͠ਖ਼͍͠ͷ͔ʢʁʣ ϑΣΞʹͳ͍ͬͯΔͷ͔ʢʁʣͱ͍͏ٙ໰͕
  34. 5 5 ౳෼Λݸʑʹ 20 ֊૚ωετ (layout_weight) ιʔείʔυˍը໘ <?xml version="1.0" encoding="utf-8"?>


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <LinearLayout
 android:layout_width="0dp"
 android:layout_height="wrap_content"
 android:layout_weight="1">
 <Button
 android:layout_width="0dp"
 android:layout_height="@dimen/height_button"
 android:layout_weight="1" />
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>
 47
  35. Measure Layout Draw ߹ܭ 1 ճ໨ 0.050 ms 6.173 ms

    3.936 ms 10.159 ms 2 ճ໨ 0.092 ms 18.686 ms 9.027 ms 27 .805 ms 3 ճ໨ 0.041 ms 8.969 ms 14.049 ms 23.059 ms 4 ճ໨ 0.042 ms 6.624 ms 4.788 ms 11.454 ms 5 ճ໨ 0.041 ms 6.789 ms 33.794 ms 40.624 ms ฏۉ 0.053 ms 9.448 ms 13.119 ms 22.620 ms 5 5 ౳෼Λݸʑʹ 20 ֊૚ωετ
 (layout_weight) ܭଌ݁Ռ 1120 views 48
  36. Measure Layout Draw ߹ܭ 1 ճ໨ 0.048 ms 1.639 ms

    2.964 ms 4.651 ms 2 ճ໨ 0.043 ms 1.937 ms 3.245 ms 5.225 ms 3 ճ໨ 0.048 ms 2.375 ms 4.489 ms 6.912 ms 4 ճ໨ 0.040 ms 1.784 ms 3.584 ms 5.408 ms 5 ճ໨ 0.044 ms 1.913 ms 4.098 ms 6.055 ms ฏۉ 0.045 ms 1.930 ms 3.676 ms 5.650 ms 6 5 ౳෼Λݸʑʹ 20 ֊૚ωετ
 (PercentRelativeLayout) ܭଌ݁Ռ 1120 views 49
  37. Measure Layout Draw ߹ܭ 1 ճ໨ 0.049 ms 0.944 ms

    3.424 ms 4.417 ms 2 ճ໨ 0.047 ms 0.923 ms 6.751 ms 7 .721 ms 3 ճ໨ 0.042 ms 1.253 ms 3.303 ms 4.598 ms 4 ճ໨ 0.044 ms 0.847 ms 3.401 ms 4.292 ms 5 ճ໨ 0.040 ms 0.890 ms 6.240 ms 7 .170 ms ฏۉ 0.044 ms 0.971 ms 4.624 ms 5.640 ms : 5 ౳෼Λݸʑʹ 20 ֊૚ωετ
 (ԣ෯Λ dp ࢦఆ) ܭଌ݁Ռ 1120 views 50
  38. 5 ౳෼Λݸʑʹ 20 ֊૚ωετ
 ·ͱΊʢAndroid 6.0ʣ layout_weight ஍ࠈʹ͢Δͱඳը͕࣌ؒ஗͘ͳΔ͜ͱ͸
 ֬ೝͰ͖ͨ ΤϛϡϨʔλͱ࣮୺຤

    (Nexus 7) Ͱ ListView ΛεΫϩʔϧͤͯ͞ Έͨͱ͜Ζ layout_weight ͱ PercentRelativeLayout ͱ ԣ෯ dp ࢦఆͰಈ͖ʹҧ͍͕͋Δ͔ͱݴΘΕΔͱͦ͏Ͱ΋ͳ͍ʢʁʣ layout_weight PercentRelative
 Layout ԣ෯Λ dp ࢦఆ ߹ܭ࣌ؒͷฏۉ 22.620 ms 5.650 ms 5.640 ms 51
  39. 5 ౳෼Λݸʑʹ 20 ֊૚ωετ
 ·ͱΊʢAndroid 6.0ʣ layout_weight=“1” ͸ઃఆͰ͖Δͱ͜Ζશͯʹઃ ఆͯ͠Έ·ͨ͠ʢ100 ݸʣ

    Ռͨͯ͠ൺֱ͢Δ৚݅ͱͯ͠ਖ਼͍͠ͷ͔ʢʁʣ ϑΣΞʹͳ͍ͬͯΔͷ͔ʢʁʣͱ͍͏ٙ໰͕