summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-02-07 20:33:44 -0800
committerXavier Ducrohet <xav@android.com>2011-02-07 20:33:44 -0800
commitabc33e014d4490dc993d1453e2589f538dbd7bbe (patch)
tree6461035cd92b2254805dd6e2a153f78f74273595 /tools
parent8635908da1a9f0b3e7ba9bd11ce7104b38f76756 (diff)
downloadframeworks_base-abc33e014d4490dc993d1453e2589f538dbd7bbe.zip
frameworks_base-abc33e014d4490dc993d1453e2589f538dbd7bbe.tar.gz
frameworks_base-abc33e014d4490dc993d1453e2589f538dbd7bbe.tar.bz2
LayoutLib: fix the background of title/action bars.
The bars are supposed to sit on top of the window so that if they are transparent (which is the default case for the action bar), the window background shows through. Fix this using a layout to represent the window content (all but the system bar) in which the title/action bars and the layout content sits. This layout receives the windowBackground drawable. Change-Id: I8072c5ff52f585fa32acb589d8526e1c13cbcd94
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java1
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java1
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java2
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java39
4 files changed, 30 insertions, 13 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
index 70c507c..771d89a 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
@@ -65,7 +65,6 @@ abstract class CustomBar extends LinearLayout {
super(context);
setOrientation(LinearLayout.HORIZONTAL);
setGravity(Gravity.CENTER_VERTICAL);
- setBackgroundColor(0xFF000000);
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
index e3022b4..04d06e4 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
@@ -33,6 +33,7 @@ public class PhoneSystemBar extends CustomBar {
super(context, density, "/bars/tablet_system_bar.xml");
setGravity(mGravity | Gravity.RIGHT);
+ setBackgroundColor(0xFF000000);
// Cannot access the inside items through id because no R.id values have been
// created for them.
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java
index db1efdb..5ca68fa 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java
@@ -31,6 +31,8 @@ public class TabletSystemBar extends CustomBar {
public TabletSystemBar(Context context, Density density) throws XmlPullParserException {
super(context, density, "/bars/tablet_system_bar.xml");
+ setBackgroundColor(0xFF000000);
+
// Cannot access the inside items through id because no R.id values have been
// created for them.
// We do know the order though.
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index 3e5127e..136b205 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -204,8 +204,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
SessionParams params = getParams();
BridgeContext context = getContext();
+ // the view group that receives the window background.
+ ViewGroup backgroundView = null;
+
if (mWindowIsFloating || params.isForceNoDecor()) {
- mViewRoot = mContentRoot = new FrameLayout(context);
+ backgroundView = mViewRoot = mContentRoot = new FrameLayout(context);
} else {
/*
* we're creating the following layout
@@ -213,10 +216,13 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
+-------------------------------------------------+
| System bar (only in phone UI) |
+-------------------------------------------------+
- | Title/Action bar (optional) |
- +-------------------------------------------------+
- | Content, vertical extending |
- | |
+ | (Layout with background drawable) |
+ | +---------------------------------------------+ |
+ | | Title/Action bar (optional) | |
+ | +---------------------------------------------+ |
+ | | Content, vertical extending | |
+ | | | |
+ | +---------------------------------------------+ |
+-------------------------------------------------+
| System bar (only in tablet UI) |
+-------------------------------------------------+
@@ -241,6 +247,16 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
}
}
+ LinearLayout backgroundLayout = new LinearLayout(context);
+ backgroundView = backgroundLayout;
+ backgroundLayout.setOrientation(LinearLayout.VERTICAL);
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ layoutParams.weight = 1;
+ backgroundLayout.setLayoutParams(layoutParams);
+ topLayout.addView(backgroundLayout);
+
+
// if the theme says no title/action bar, then the size will be 0
if (mActionBarSize > 0) {
try {
@@ -250,7 +266,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
actionBar.setLayoutParams(
new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, mActionBarSize));
- topLayout.addView(actionBar);
+ backgroundLayout.addView(actionBar);
} catch (XmlPullParserException e) {
}
@@ -261,7 +277,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
titleBar.setLayoutParams(
new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, mTitleBarSize));
- topLayout.addView(titleBar);
+ backgroundLayout.addView(titleBar);
} catch (XmlPullParserException e) {
}
@@ -270,11 +286,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
// content frame
mContentRoot = new FrameLayout(context);
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
+ layoutParams = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
layoutParams.weight = 1;
mContentRoot.setLayoutParams(layoutParams);
- topLayout.addView(mContentRoot);
+ backgroundLayout.addView(mContentRoot);
if (mSystemBarSize > 0) {
// system bar
@@ -289,7 +305,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
}
}
-
}
@@ -314,9 +329,9 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
postInflateProcess(view, params.getProjectCallback());
// get the background drawable
- if (mWindowBackground != null) {
+ if (mWindowBackground != null && backgroundView != null) {
Drawable d = ResourceHelper.getDrawable(mWindowBackground, context);
- mContentRoot.setBackgroundDrawable(d);
+ backgroundView.setBackgroundDrawable(d);
}
return SUCCESS.createResult();