Example usage for android.graphics.drawable LayerDrawable getPadding

List of usage examples for android.graphics.drawable LayerDrawable getPadding

Introduction

In this page you can find the example usage for android.graphics.drawable LayerDrawable getPadding.

Prototype

@Override
    public boolean getPadding(Rect padding) 

Source Link

Usage

From source file:org.kde.necessitas.ministro.ExtractStyle.java

private JSONObject getLayerDrawable(Object drawable, String filename) {
    JSONObject json = new JSONObject();
    LayerDrawable layers = (LayerDrawable) drawable;
    final int nr = layers.getNumberOfLayers();
    try {/*  ww  w  .  ja v a2 s  .co  m*/
        JSONArray array = new JSONArray();
        for (int i = 0; i < nr; i++) {
            JSONObject layerJsonObject = getDrawable(layers.getDrawable(i), filename + "__" + layers.getId(i));
            layerJsonObject.put("id", layers.getId(i));
            array.put(layerJsonObject);
        }
        json.put("type", "layer");
        Rect padding = new Rect();
        if (layers.getPadding(padding))
            json.put("padding", getJsonRect(padding));
        json.put("layers", array);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return json;
}