From d9085b9775d76bffa38c7192048cd8870c32f926 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 26 Nov 2012 23:52:06 +0100 Subject: [PATCH] Improve layoutissue --- .../net/osmand/plus/views/MapInfoLayer.java | 2 +- .../osmand/plus/views/MapStackControl.java | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index c7491d7b14..b26ec34267 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -443,7 +443,7 @@ public class MapInfoLayer extends OsmandMapLayer { // 3. put into frame parent layout controls FrameLayout parent = (FrameLayout) view.getParent(); // status bar hides own top part - int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom; + int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom ; // we want that status bar lays over map stack controls topMargin -= topRectPadding.top; diff --git a/OsmAnd/src/net/osmand/plus/views/MapStackControl.java b/OsmAnd/src/net/osmand/plus/views/MapStackControl.java index 2dc52bc948..05ec3465f3 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapStackControl.java +++ b/OsmAnd/src/net/osmand/plus/views/MapStackControl.java @@ -152,8 +152,9 @@ public class MapStackControl extends ViewGroup { c.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); w = Math.max(w, c.getMeasuredWidth()); if (h > 0) { - h -= c.getPaddingTop(); h -= prevBot; + } else { + h += c.getPaddingTop(); } h += c.getMeasuredHeight(); prevBot = c.getPaddingBottom(); @@ -171,7 +172,6 @@ public class MapStackControl extends ViewGroup { w = Math.max(w, c.getMeasuredWidth()); h -= c.getPaddingBottom(); if (h > 0) { - h -= c.getPaddingTop(); h -= prevBot; } h += c.getMeasuredHeight(); @@ -187,7 +187,6 @@ public class MapStackControl extends ViewGroup { } } if (isCollapsible) { -// h -= prevBot; h += expandView.getDrawable().getMinimumHeight(); w = Math.max(w, expandView.getDrawable().getMinimumWidth()); } @@ -195,14 +194,18 @@ public class MapStackControl extends ViewGroup { setMeasuredDimension(w, h); } + private final static int MAGIC_CONSTANT_STACK = 3; @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { int y = 0; int cw = right - left; for (View c : stackViews) { if (c.getVisibility() != View.GONE) { - if (y > 0) { - y -= c.getPaddingTop(); + if (y == 0) { + y += c.getPaddingTop(); + } else { + // magic constant (should be removed when image will be recropped) + y -= MAGIC_CONSTANT_STACK; } c.layout(0, y, cw, y + c.getMeasuredHeight()); y += c.getMeasuredHeight(); @@ -213,8 +216,11 @@ public class MapStackControl extends ViewGroup { for (View c : collapsedViews) { if (!isCollapsed) { if (c.getVisibility() != View.GONE) { - if (y > 0) { - y -= c.getPaddingTop(); + if (y == 0) { + y += c.getPaddingTop(); + } else { + // magic constant (should be removed when image will be recropped) + y -= MAGIC_CONSTANT_STACK; } c.layout(0, y, cw, y + c.getMeasuredHeight()); y += c.getMeasuredHeight();