Skip to content

Commit 136a10a

Browse files
committed
Fix bug 5594320 - Overlay action bar decor layout causes two measure passes
The existing action bar overlay decor layouts hit a case in RelativeLayout that causes two measure passes for the main content. As this can be expensive, stick the bar and the content overlay into their own sub-layout and switch things to use a FrameLayout at the top level instead. Be explicit about the layout_width/height on ActionBar-containing decor layouts as the older decor layouts are. Change-Id: I4330f0f25841dd8058b94a320f93bf67fb56bf17
1 parent 030bb99 commit 136a10a

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

core/res/res/layout/screen_action_bar.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This is an optimized layout for a screen with the Action Bar enabled.
1919
-->
2020

2121
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
22+
android:layout_width="match_parent"
23+
android:layout_height="match_parent"
2224
android:orientation="vertical"
2325
android:fitsSystemWindows="true">
2426
<com.android.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"

core/res/res/layout/screen_action_bar_overlay.xml

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,45 @@ This is an optimized layout for a screen with
1919
the Action Bar enabled overlaying application content.
2020
-->
2121

22-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
22+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
23+
android:layout_width="match_parent"
24+
android:layout_height="match_parent"
2325
android:fitsSystemWindows="true">
2426
<FrameLayout android:id="@android:id/content"
2527
android:layout_width="match_parent"
2628
android:layout_height="match_parent" />
27-
<com.android.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
28-
android:layout_width="match_parent"
29-
android:layout_height="wrap_content"
30-
style="?android:attr/actionBarStyle"
31-
android:gravity="top">
32-
<com.android.internal.widget.ActionBarView
33-
android:id="@+id/action_bar"
34-
android:layout_width="match_parent"
35-
android:layout_height="wrap_content"
36-
style="?android:attr/actionBarStyle" />
37-
<com.android.internal.widget.ActionBarContextView
38-
android:id="@+id/action_context_bar"
29+
<LinearLayout android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
android:layout_gravity="top">
32+
<com.android.internal.widget.ActionBarContainer android:id="@+id/action_bar_container"
3933
android:layout_width="match_parent"
4034
android:layout_height="wrap_content"
41-
android:visibility="gone"
42-
style="?android:attr/actionModeStyle" />
43-
</com.android.internal.widget.ActionBarContainer>
44-
<ImageView android:src="?android:attr/windowContentOverlay"
45-
android:scaleType="fitXY"
46-
android:layout_width="match_parent"
47-
android:layout_height="wrap_content"
48-
android:layout_below="@id/action_bar_container" />
35+
android:layout_alignParentTop="true"
36+
style="?android:attr/actionBarStyle"
37+
android:gravity="top">
38+
<com.android.internal.widget.ActionBarView
39+
android:id="@+id/action_bar"
40+
android:layout_width="match_parent"
41+
android:layout_height="wrap_content"
42+
style="?android:attr/actionBarStyle" />
43+
<com.android.internal.widget.ActionBarContextView
44+
android:id="@+id/action_context_bar"
45+
android:layout_width="match_parent"
46+
android:layout_height="wrap_content"
47+
android:visibility="gone"
48+
style="?android:attr/actionModeStyle" />
49+
</com.android.internal.widget.ActionBarContainer>
50+
<ImageView android:src="?android:attr/windowContentOverlay"
51+
android:scaleType="fitXY"
52+
android:layout_width="match_parent"
53+
android:layout_height="wrap_content"
54+
android:layout_below="@id/action_bar_container" />
55+
</LinearLayout>
4956
<com.android.internal.widget.ActionBarContainer android:id="@+id/split_action_bar"
5057
android:layout_width="match_parent"
5158
android:layout_height="wrap_content"
52-
android:layout_alignParentBottom="true"
59+
android:layout_gravity="bottom"
5360
style="?android:attr/actionBarSplitStyle"
5461
android:visibility="gone"
5562
android:gravity="center"/>
56-
</RelativeLayout>
63+
</FrameLayout>

core/res/res/layout/screen_simple.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ enabled.
2222
-->
2323

2424
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
25+
android:layout_width="match_parent"
26+
android:layout_height="match_parent"
2527
android:fitsSystemWindows="true"
2628
android:orientation="vertical">
2729
<ViewStub android:id="@+id/action_mode_bar_stub"

core/res/res/layout/screen_simple_overlay_action_mode.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ enabled.
2121
-->
2222

2323
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
24+
android:layout_width="match_parent"
25+
android:layout_height="match_parent"
2426
android:fitsSystemWindows="true">
2527
<FrameLayout
2628
android:id="@android:id/content"

0 commit comments

Comments
 (0)