diff options
author | Diego Perez <diegoperez@google.com> | 2015-08-04 14:16:09 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-08-04 14:16:09 +0000 |
commit | e76c916a8ac455d9f08baef97570504a628030df (patch) | |
tree | 1748d0f4b9676e2e915adb396715c4d94434d4df /android | |
parent | 566a6095578766caecd13d637cc15831f278ac22 (diff) | |
parent | f86bb574fb4f6acf4e2b29469a3dba027af81601 (diff) | |
download | idea-e76c916a8ac455d9f08baef97570504a628030df.tar.gz |
Merge "Only setting height to 1 when we are reducing the width" into studio-1.4-dev automerge: 3bc9319
automerge: f86bb57
* commit 'f86bb574fb4f6acf4e2b29469a3dba027af81601':
Only setting height to 1 when we are reducing the width
Diffstat (limited to 'android')
-rw-r--r-- | android/src/com/android/tools/swing/layoutlib/AndroidPreviewPanel.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/android/src/com/android/tools/swing/layoutlib/AndroidPreviewPanel.java b/android/src/com/android/tools/swing/layoutlib/AndroidPreviewPanel.java index 7a12d14441c..005fa2ed61a 100644 --- a/android/src/com/android/tools/swing/layoutlib/AndroidPreviewPanel.java +++ b/android/src/com/android/tools/swing/layoutlib/AndroidPreviewPanel.java @@ -116,6 +116,7 @@ public class AndroidPreviewPanel extends JComponent implements Scrollable { private double myScale = 1.0; private Dimension myLastRenderedSize; private Dimension myCachedPreferredSize; + private int myCurrentWidth; public AndroidPreviewPanel(@NotNull Configuration configuration) { myConfiguration = configuration; @@ -134,9 +135,15 @@ public class AndroidPreviewPanel extends JComponent implements Scrollable { Dimension currentSize = getSize(); synchronized (myGraphicsLayoutRendererLock) { if (myGraphicsLayoutRenderer != null && !currentSize.equals(previousSize)) { - // Because we use GraphicsLayoutRender in vertical scroll mode, the height passed it's only a minimum. If the actual rendering results - // in a bigger size, the GraphicsLayoutRenderer.getPreferredSize() call will return the correct size. - myGraphicsLayoutRenderer.setSize(width, 1); + // Because we use GraphicsLayoutRender in vertical scroll mode, the height passed it's only a minimum. + // If the actual rendering results in a bigger size, the GraphicsLayoutRenderer.getPreferredSize() + // call will return the correct size. + + // Older versions of layoutlib do not handle correctly when 1 is passed and don't always recalculate + // the height if the width hasn't decreased. + // We workaround that by keep track of the last known width and passing height 1 when it decreases. + myGraphicsLayoutRenderer.setSize(width, (myCurrentWidth < width) ? 1 : height); + myCurrentWidth = width; } } } |