Merge "LayoutLib: fix the background of title/action bars." into honeycomb
This commit is contained in:
committed by
Android (Google) Code Review
commit
dc3fc3dc27
@@ -65,7 +65,6 @@ abstract class CustomBar extends LinearLayout {
|
|||||||
super(context);
|
super(context);
|
||||||
setOrientation(LinearLayout.HORIZONTAL);
|
setOrientation(LinearLayout.HORIZONTAL);
|
||||||
setGravity(Gravity.CENTER_VERTICAL);
|
setGravity(Gravity.CENTER_VERTICAL);
|
||||||
setBackgroundColor(0xFF000000);
|
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
|
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class PhoneSystemBar extends CustomBar {
|
|||||||
super(context, density, "/bars/tablet_system_bar.xml");
|
super(context, density, "/bars/tablet_system_bar.xml");
|
||||||
|
|
||||||
setGravity(mGravity | Gravity.RIGHT);
|
setGravity(mGravity | Gravity.RIGHT);
|
||||||
|
setBackgroundColor(0xFF000000);
|
||||||
|
|
||||||
// Cannot access the inside items through id because no R.id values have been
|
// Cannot access the inside items through id because no R.id values have been
|
||||||
// created for them.
|
// created for them.
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ public class TabletSystemBar extends CustomBar {
|
|||||||
public TabletSystemBar(Context context, Density density) throws XmlPullParserException {
|
public TabletSystemBar(Context context, Density density) throws XmlPullParserException {
|
||||||
super(context, density, "/bars/tablet_system_bar.xml");
|
super(context, density, "/bars/tablet_system_bar.xml");
|
||||||
|
|
||||||
|
setBackgroundColor(0xFF000000);
|
||||||
|
|
||||||
// Cannot access the inside items through id because no R.id values have been
|
// Cannot access the inside items through id because no R.id values have been
|
||||||
// created for them.
|
// created for them.
|
||||||
// We do know the order though.
|
// We do know the order though.
|
||||||
|
|||||||
@@ -204,8 +204,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
SessionParams params = getParams();
|
SessionParams params = getParams();
|
||||||
BridgeContext context = getContext();
|
BridgeContext context = getContext();
|
||||||
|
|
||||||
|
// the view group that receives the window background.
|
||||||
|
ViewGroup backgroundView = null;
|
||||||
|
|
||||||
if (mWindowIsFloating || params.isForceNoDecor()) {
|
if (mWindowIsFloating || params.isForceNoDecor()) {
|
||||||
mViewRoot = mContentRoot = new FrameLayout(context);
|
backgroundView = mViewRoot = mContentRoot = new FrameLayout(context);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* we're creating the following layout
|
* we're creating the following layout
|
||||||
@@ -213,10 +216,13 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
+-------------------------------------------------+
|
+-------------------------------------------------+
|
||||||
| System bar (only in phone UI) |
|
| System bar (only in phone UI) |
|
||||||
+-------------------------------------------------+
|
+-------------------------------------------------+
|
||||||
| Title/Action bar (optional) |
|
| (Layout with background drawable) |
|
||||||
+-------------------------------------------------+
|
| +---------------------------------------------+ |
|
||||||
| Content, vertical extending |
|
| | Title/Action bar (optional) | |
|
||||||
| |
|
| +---------------------------------------------+ |
|
||||||
|
| | Content, vertical extending | |
|
||||||
|
| | | |
|
||||||
|
| +---------------------------------------------+ |
|
||||||
+-------------------------------------------------+
|
+-------------------------------------------------+
|
||||||
| System bar (only in tablet UI) |
|
| 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 the theme says no title/action bar, then the size will be 0
|
||||||
if (mActionBarSize > 0) {
|
if (mActionBarSize > 0) {
|
||||||
try {
|
try {
|
||||||
@@ -250,7 +266,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
actionBar.setLayoutParams(
|
actionBar.setLayoutParams(
|
||||||
new LinearLayout.LayoutParams(
|
new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT, mActionBarSize));
|
LayoutParams.MATCH_PARENT, mActionBarSize));
|
||||||
topLayout.addView(actionBar);
|
backgroundLayout.addView(actionBar);
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -261,7 +277,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
titleBar.setLayoutParams(
|
titleBar.setLayoutParams(
|
||||||
new LinearLayout.LayoutParams(
|
new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT, mTitleBarSize));
|
LayoutParams.MATCH_PARENT, mTitleBarSize));
|
||||||
topLayout.addView(titleBar);
|
backgroundLayout.addView(titleBar);
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -270,11 +286,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
|
|
||||||
// content frame
|
// content frame
|
||||||
mContentRoot = new FrameLayout(context);
|
mContentRoot = new FrameLayout(context);
|
||||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
layoutParams = new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||||
layoutParams.weight = 1;
|
layoutParams.weight = 1;
|
||||||
mContentRoot.setLayoutParams(layoutParams);
|
mContentRoot.setLayoutParams(layoutParams);
|
||||||
topLayout.addView(mContentRoot);
|
backgroundLayout.addView(mContentRoot);
|
||||||
|
|
||||||
if (mSystemBarSize > 0) {
|
if (mSystemBarSize > 0) {
|
||||||
// system bar
|
// 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());
|
postInflateProcess(view, params.getProjectCallback());
|
||||||
|
|
||||||
// get the background drawable
|
// get the background drawable
|
||||||
if (mWindowBackground != null) {
|
if (mWindowBackground != null && backgroundView != null) {
|
||||||
Drawable d = ResourceHelper.getDrawable(mWindowBackground, context);
|
Drawable d = ResourceHelper.getDrawable(mWindowBackground, context);
|
||||||
mContentRoot.setBackgroundDrawable(d);
|
backgroundView.setBackgroundDrawable(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS.createResult();
|
return SUCCESS.createResult();
|
||||||
|
|||||||
Reference in New Issue
Block a user