From 018f0ada85957d49db115b11dd630b2e94f9fdfb Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 19 Nov 2010 13:54:48 -0800 Subject: ADT/Layoutlib: update API to control how layout expands. Previous API was a single on/off to let the layouts expand at render time depending on how much space they needed. The new API can now control expansion is horizontal and/or vertical (or not at all) Basic implementation in the editor, with a manual detect of "ScrollView" as top element. We should make the ViewRule handle this somehow. Change-Id: Idc503bc0d1d3df98fbf01cc84625952ca55a8afb --- .../src/com/android/layoutlib/api/SceneParams.java | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'layoutlib_api/src/com/android/layoutlib/api') diff --git a/layoutlib_api/src/com/android/layoutlib/api/SceneParams.java b/layoutlib_api/src/com/android/layoutlib/api/SceneParams.java index 6b8f781..36c7a0a 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/SceneParams.java +++ b/layoutlib_api/src/com/android/layoutlib/api/SceneParams.java @@ -20,11 +20,34 @@ import java.util.Map; public class SceneParams { + public static enum RenderingMode { + NORMAL(false, false), + V_SCROLL(false, true), + H_SCROLL(true, false), + FULL_EXPAND(true, true); + + private final boolean mHorizExpand; + private final boolean mVertExpand; + + private RenderingMode(boolean horizExpand, boolean vertExpand) { + mHorizExpand = horizExpand; + mVertExpand = vertExpand; + } + + public boolean isHorizExpand() { + return mHorizExpand; + } + + public boolean isVertExpand() { + return mVertExpand; + } + } + private IXmlPullParser mLayoutDescription; private Object mProjectKey; private int mScreenWidth; private int mScreenHeight; - private boolean mRenderFullSize; + private RenderingMode mRenderingMode; private int mDensity; private float mXdpi; private float mYdpi; @@ -44,8 +67,7 @@ public class SceneParams { * @param projectKey An Object identifying the project. This is used for the cache mechanism. * @param screenWidth the screen width * @param screenHeight the screen height - * @param renderFullSize if true, the rendering will render the full size needed by the - * layout. This size is never smaller than screenWidth x screenHeight. + * @param renderingMode The rendering mode. * @param density the density factor for the screen. * @param xdpi the screen actual dpi in X * @param ydpi the screen actual dpi in Y @@ -65,7 +87,7 @@ public class SceneParams { */ public SceneParams(IXmlPullParser layoutDescription, Object projectKey, - int screenWidth, int screenHeight, boolean renderFullSize, + int screenWidth, int screenHeight, RenderingMode renderingMode, int density, float xdpi, float ydpi, String themeName, boolean isProjectTheme, Map> projectResources, @@ -75,7 +97,7 @@ public class SceneParams { mProjectKey = projectKey; mScreenWidth = screenWidth; mScreenHeight = screenHeight; - mRenderFullSize = renderFullSize; + mRenderingMode = renderingMode; mDensity = density; mXdpi = xdpi; mYdpi = ydpi; @@ -96,7 +118,7 @@ public class SceneParams { mProjectKey = params.mProjectKey; mScreenWidth = params.mScreenWidth; mScreenHeight = params.mScreenHeight; - mRenderFullSize = params.mRenderFullSize; + mRenderingMode = params.mRenderingMode; mDensity = params.mDensity; mXdpi = params.mXdpi; mYdpi = params.mYdpi; @@ -131,8 +153,8 @@ public class SceneParams { return mScreenHeight; } - public boolean getRenderFullSize() { - return mRenderFullSize; + public RenderingMode getRenderingMode() { + return mRenderingMode; } public int getDensity() { -- cgit v1.1