Using nine-patch layers

Nine-patch layer is used for showing framed images and buttons that change in size, because it scales the frame to match the size of the layer. Nine-patch layer scales images in the layer in a controlled way, instead of scaling them as one unit.

Nine-patch layer places nine images in a 3x3 grid. The images on the edges form the frame, while the center image holds the content of the nine-patch layer.

When you create nine-patch layers, keep the following in mind:

Creating a nine-patch layer

To create a nine-patch layer:

  1. In the Project right-click the scene where you want to create a nine-patch layer and select Create > Nine-Patch Layer.
  2. In the Properties set the Nine-Patch Layer Textures properties to the images you want use for the nine-patch layer:
  3. (Optional) You can control how the top, right, bottom, and left textures are displayed.
    1. In the Library select the texture and set the Wrap Mode property.
    2. In the Project select the nine-patch layer and in the Properties set the texture stretch property for the textures you want to control (Top Texture Type, Bottom Texture Type, Left Texture TypeRight Texture TypeCenter Texture Type).
    Wrap Mode property valueTexture Stretch property valueDescription
    ClampStretchDefault value. Scale the texture to fill the space between the corner textures of the nine-patch layer.
    ClampWrapExtend the last column or row of pixels of the selected texture when the width or height of the space between the corner textures of the nine-patch layer exceed the width or height of the selected texture.
    RepeatStretchScale the texture to fill the space between the corner textures of the nine-patch layer.
    RepeatWrapTile the texture when the width or height of the space between the corner textures of the nine-patch layer exceed the width or height of the selected texture.

See also

Layers