aboutsummaryrefslogtreecommitdiffstats
path: root/layoutlib_api/src/com/android/layoutlib/api/SceneParams.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2010-11-15 15:35:15 -0800
committerTor Norbye <tnorbye@google.com>2010-11-19 12:43:16 -0800
commita2d7874ed23bfc2fa7665cc84901e0f4781b4e51 (patch)
tree58f81c6ae19363a31335b3874c0fa617d5ea3396 /layoutlib_api/src/com/android/layoutlib/api/SceneParams.java
parenta6ed5f2625d825a85cb7579b7017b1ea02a984ee (diff)
downloadsdk-a2d7874ed23bfc2fa7665cc84901e0f4781b4e51.zip
sdk-a2d7874ed23bfc2fa7665cc84901e0f4781b4e51.tar.gz
sdk-a2d7874ed23bfc2fa7665cc84901e0f4781b4e51.tar.bz2
Add per-view custom initialization logic
This changeset adds support for adding custom-logic to initialize views, both to add children and default attributes and to customize layout attributes when added to a new parent. First, there is a new "onCreate" hook which is called to notify a view rule that an instance of its corresponding view has been created. This lets the ViewRule perform custom initialization of the object. The ViewRule is told what type of insertion occurred, such that it can distinguish between a newly created view, a view that is the result of a copy/paste, and a view that is part of a move operation. The changeset adds a number of new ViewRules which take advantage of this: - A TabHost rule creates the various skeleton children that are required, such as a TabWidget child with id @android:id/tabs and a FrameLayout child with id @android:id/tabcontent - A DialerFilter rule creates the mandatory EditText children ("hint" and "primary") - The HorizontalScrollView rule creates a horizontal LinearLayout child - The ImageButton and ImageViewButtons initialize the "src" attribute to a sample image - The MapViewRule initializes the apiKey attribute In addition, views are also notified when a new view is added as a child, such that they can perform additional customizations, in the form of an "onInsert" event. The most important application of this is LinearLayoutRule, which uses this to set reasonable defaults for the layout_width and layout_height parameters. It uses metadata (which is currently built into ADT but would ideally migrate into our XML config files) to determine whether a given child prefers to grow horizontally, grow vertically, both, or neither, depending on the surrounding parent context. For example, an EditText will default to filling the parent width if it is in a vertical LinearLayout, but it will not grow vertically in a horizontal linear layout. And so on. Various other rules also use the onInsert event to tweak children attributes. A ScrollView will for example always initialize its single child to match parent. Views can now also add plain menu items into the context menu, and the TableViewRule adds one such action: "Add Row", which appends a new row into the table. The Palette Preview code also invokes these creation hooks, such that if you for example drag a DialerFilter it can properly render since the mandatory children are created up front. This required various changes to the preview code to be able to handle XML edits by the rules. Finally, this changeset includes various other misc changes that I performed at the same time: - Removed SWT dependency from the ViewRule classes (SWT Rectangle use in Rect) - Fixed AbsoluteLayout unit test (issue 3203560) - Fixed positioning of the preview outline in LinearLayout when only one of the dimensions are clipped due to a smaller target layout Change-Id: I5956fe4e7a31a20b8dd2f9d9b0c1f90e2f75d68a
Diffstat (limited to 'layoutlib_api/src/com/android/layoutlib/api/SceneParams.java')
0 files changed, 0 insertions, 0 deletions