diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-08-26 20:21:38 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-26 20:21:38 +0000 |
commit | de8da2793df3b3cb05215fa5dd02542548a54b9f (patch) | |
tree | b9dafedcc3487e2ece8078c5b1e92389bd61bf13 /tools/layoutlib/bridge/src | |
parent | 963cac18adefa1e60a827183b95b4e61a23929d3 (diff) | |
parent | e54dbc4ac74d110c4121932a22d04447a0e15b65 (diff) | |
download | frameworks_base-de8da2793df3b3cb05215fa5dd02542548a54b9f.zip frameworks_base-de8da2793df3b3cb05215fa5dd02542548a54b9f.tar.gz frameworks_base-de8da2793df3b3cb05215fa5dd02542548a54b9f.tar.bz2 |
am e54dbc4a: am 3ba16c1d: LayoutLib: fix layout when nav bar is absent. [DO NOT MERGE]
* commit 'e54dbc4ac74d110c4121932a22d04447a0e15b65':
LayoutLib: fix layout when nav bar is absent. [DO NOT MERGE]
Diffstat (limited to 'tools/layoutlib/bridge/src')
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java index 89d8319..d1c9f21 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java @@ -165,13 +165,13 @@ class Layout extends RelativeLayout { FrameLayout contentRoot = new FrameLayout(getContext()); LayoutParams params = createLayoutParams(MATCH_PARENT, MATCH_PARENT); int rule = mBuilder.isNavBarVertical() ? START_OF : ABOVE; - if (mBuilder.solidBars()) { + if (mBuilder.hasNavBar() && mBuilder.solidBars()) { params.addRule(rule, getId(ID_NAV_BAR)); } int below = -1; if (mBuilder.mActionBarSize <= 0 && mBuilder.mTitleBarSize > 0) { below = getId(ID_TITLE_BAR); - } else if (mBuilder.solidBars()) { + } else if (mBuilder.hasStatusBar() && mBuilder.solidBars()) { below = getId(ID_STATUS_BAR); } if (below != -1) { @@ -238,10 +238,10 @@ class Layout extends RelativeLayout { } LayoutParams layoutParams = createLayoutParams(MATCH_PARENT, MATCH_PARENT); int rule = mBuilder.isNavBarVertical() ? START_OF : ABOVE; - if (mBuilder.solidBars()) { + if (mBuilder.hasNavBar() && mBuilder.solidBars()) { layoutParams.addRule(rule, getId(ID_NAV_BAR)); } - if (mBuilder.solidBars()) { + if (mBuilder.hasStatusBar() && mBuilder.solidBars()) { layoutParams.addRule(BELOW, getId(ID_STATUS_BAR)); } actionBar.getRootView().setLayoutParams(layoutParams); @@ -254,7 +254,7 @@ class Layout extends RelativeLayout { int simulatedPlatformVersion) { TitleBar titleBar = new TitleBar(context, title, simulatedPlatformVersion); LayoutParams params = createLayoutParams(MATCH_PARENT, mBuilder.mTitleBarSize); - if (mBuilder.solidBars()) { + if (mBuilder.hasStatusBar() && mBuilder.solidBars()) { params.addRule(BELOW, getId(ID_STATUS_BAR)); } if (mBuilder.isNavBarVertical() && mBuilder.solidBars()) { @@ -333,10 +333,6 @@ class Layout extends RelativeLayout { findNavBar(); } - public boolean isNavBarVertical() { - return mNavBarOrientation == VERTICAL; - } - private void findBackground() { if (!mParams.isBgColorOverridden()) { mWindowBackground = mResources.findItemInTheme(ATTR_WINDOW_BACKGROUND, true); @@ -444,16 +440,27 @@ class Layout extends RelativeLayout { } /** - * Return if both status bar and nav bar are solid (content doesn't overlap with these - * bars). + * Return true if the status bar or nav bar are present, they are not translucent (i.e + * content doesn't overlap with them). */ private boolean solidBars() { - return hasNavBar() && !mTranslucentNav && !mTranslucentStatus && mStatusBarSize > 0; + return !(hasNavBar() && mTranslucentNav) && !(hasStatusBar() && mTranslucentStatus); } private boolean hasNavBar() { return Config.showOnScreenNavBar(mParams.getSimulatedPlatformVersion()) && hasSoftwareButtons() && mNavBarSize > 0; } + + private boolean hasStatusBar() { + return mStatusBarSize > 0; + } + + /** + * Return true if the nav bar is present and is vertical. + */ + private boolean isNavBarVertical() { + return hasNavBar() && mNavBarOrientation == VERTICAL; + } } } |