Android Open Source - crop Linear Button Layout






From Project

Back to project page crop.

License

The source code is released under:

Apache License

If you think the Android project crop listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.flask.crop.ui;
/*  w ww . ja  v a  2s . co  m*/
import android.graphics.Canvas;

import java.util.ArrayList;
import java.util.List;

public class LinearButtonLayout {
  private int btnGap = 5;
  private int btnSize = 80;
  private int width, height;
  private int x, y;
  private List<RoundButton> btns;
  // Basically left aligned, stack layout.

  public LinearButtonLayout(int x, int y, int width, int height) {
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;
    this.btns = new ArrayList<RoundButton>();
  }

  public void addButton(RoundButton btn) {
    btns.add(btn);
  }

  public void setStackLayout() {
    rearrange(btnGap, btnSize);
  }

  public void setFit2ScreenLayout() {
    int count = btns.size();
    int halfBtnWidth = (width - (count + 1) * btnGap) / count;
    rearrange(btnGap, halfBtnWidth);
  }

  private void rearrange(int baseX, int width) {
    for (RoundButton btn : btns) {
      btn.setRect(x + baseX, y, width, btnSize);
      baseX += btnGap + width;
    }
  }

  public void draw(Canvas canvas) {
    for (int i = 0; i < btns.size(); i++)
      btns.get(i).draw(canvas);
  }

  public List<RoundButton> getButtonList() {
    return btns;
  }
}




Java Source Code List

com.example.cropsample.BackgroundImageMakerActivity.java
com.example.cropsample.MainActivity.java
net.flask.crop.BitmapImageCropper.java
net.flask.crop.BitmapUtil.java
net.flask.crop.CropActivity.java
net.flask.crop.CropSurface.java
net.flask.crop.PressEvent.java
net.flask.crop.ui.BTN.java
net.flask.crop.ui.LinearButtonLayout.java
net.flask.crop.ui.MarqueeBox.java
net.flask.crop.ui.RoundButton.java
net.flask.crop.ui.SelectionBox.java