FloatingActionButtonHandler extends ImageViewHandler { @Override @NotNull @Language("XML") public String getXml(@NotNull String tagName, @NotNull XmlType xmlType) { XmlBuilder builder = new XmlBuilder() .startTag(tagName) .androidAttribute(ATTR_SRC, getSampleImageSrc()) .androidAttribute(ATTR_LAYOUT_WIDTH, VALUE_WRAP_CONTENT) .androidAttribute(ATTR_LAYOUT_HEIGHT, VALUE_WRAP_CONTENT) .androidAttribute("clickable", true); if (xmlType.equals(XmlType.PREVIEW_ON_PALETTE)) { builder.attribute(APP_PREFIX, "elevation", "0dp"); } return builder .endTag(tagName) .toString(); }  @Override @NotNull List<String> getInspectorProperties(); @Override @NotNull @Language("XML") String getXml(@NotNull String tagName, @NotNull XmlType xmlType); @Override @NotNull String getSampleImageSrc(); @Override double getPreviewScale(@NotNull String tagName); @Override boolean acceptsParent(@NotNull NlComponent layout, @NotNull NlComponent newChild);  }
@Test public void testGetXml() { assertThat(myHandler.getXml(SdkConstants.FLOATING_ACTION_BUTTON.defaultName(), XmlType.COMPONENT_CREATION)).isEqualTo( "<android.support.design.widget.FloatingActionButton\n" + " android:src=\"@android:drawable/ic_input_add\"\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:clickable=\"true\" />\n"); }
@Test public void testGetPreviewXml() { assertThat(myHandler.getXml(SdkConstants.FLOATING_ACTION_BUTTON.defaultName(), XmlType.PREVIEW_ON_PALETTE)).isEqualTo( "<android.support.design.widget.FloatingActionButton\n" + " android:src=\"@android:drawable/ic_input_add\"\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:clickable=\"true\"\n" + " app:elevation=\"0dp\" />\n"); }