Exemplo n.º 1
0
 // Update appearance based on values of backgroundImageDrawable, backgroundColor and shape.
 // Images take precedence over background colors.
 private void updateAppearance() {
   // If there is no background image,
   // the appearance depends solely on the background color and shape.
   if (backgroundImageDrawable == null) {
     if (shape == Component.BUTTON_SHAPE_DEFAULT) {
       if (backgroundColor == Component.COLOR_DEFAULT) {
         // If there is no background image and color is default,
         // restore original 3D bevel appearance.
         ViewUtil.setBackgroundDrawable(view, defaultButtonDrawable);
       } else {
         // Clear the background image.
         ViewUtil.setBackgroundDrawable(view, null);
         // Set to the specified color (possibly COLOR_NONE for transparent).
         TextViewUtil.setBackgroundColor(view, backgroundColor);
       }
     } else {
       // If there is no background image and the shape is something other than default,
       // create a drawable with the appropriate shape and color.
       setShape();
     }
   } else {
     // If there is a background image
     ViewUtil.setBackgroundImage(view, backgroundImageDrawable);
   }
 }
 @Override
 public void setChildHeight(AndroidViewComponent component, int height) {
   if (orientation == ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL) {
     ViewUtil.setChildHeightForHorizontalLayout(component.getView(), height);
   } else {
     ViewUtil.setChildHeightForVerticalLayout(component.getView(), height);
   }
 }
Exemplo n.º 3
0
  /**
   * Scrollable property setter method.
   *
   * @param scrollable true if the screen should be vertically scrollable
   */
  @DesignerProperty(editorType = DesignerProperty.PROPERTY_TYPE_BOOLEAN, defaultValue = "True")
  @SimpleProperty
  public void Scrollable(boolean scrollable) {
    if (this.scrollable == scrollable && frameLayout != null) {
      return;
    }

    // Remove our view from the current frameLayout.
    if (frameLayout != null) {
      frameLayout.removeAllViews();
    }

    this.scrollable = scrollable;

    frameLayout = scrollable ? new ScrollView(this) : new FrameLayout(this);
    frameLayout.addView(
        viewLayout.getLayoutManager(),
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    frameLayout.setBackgroundColor(backgroundColor);
    if (backgroundDrawable != null) {
      ViewUtil.setBackgroundImage(frameLayout, backgroundDrawable);
    }
    setContentView(frameLayout);
    frameLayout.requestLayout();
  }
Exemplo n.º 4
0
  /**
   * Specifies the path of the background image.
   *
   * <p>See {@link MediaUtil#determineMediaSource} for information about what a path can be.
   *
   * @param path the path of the background image
   */
  @DesignerProperty(editorType = DesignerProperty.PROPERTY_TYPE_ASSET, defaultValue = "")
  @SimpleProperty(
      category = PropertyCategory.APPEARANCE,
      description = "The screen background image.")
  public void BackgroundImage(String path) {
    backgroundImagePath = (path == null) ? "" : path;

    try {
      backgroundDrawable = MediaUtil.getBitmapDrawable(this, backgroundImagePath);
    } catch (IOException ioe) {
      Log.e(LOG_TAG, "Unable to load " + backgroundImagePath);
      backgroundDrawable = null;
    }

    ViewUtil.setBackgroundImage(frameLayout, backgroundDrawable);
    frameLayout.invalidate();
  }
Exemplo n.º 5
0
 @Override
 public void setChildHeight(AndroidViewComponent component, int height) {
   // A form is a vertical layout.
   ViewUtil.setChildHeightForVerticalLayout(component.getView(), height);
 }
Exemplo n.º 6
0
 @Override
 public void setChildWidth(AndroidViewComponent component, int width) {
   // A form is a vertical layout.
   ViewUtil.setChildWidthForVerticalLayout(component.getView(), width);
 }