Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 增加VisualizerView中条形图的高度_Android_Bar Chart_Visualizer - Fatal编程技术网

Android 增加VisualizerView中条形图的高度

Android 增加VisualizerView中条形图的高度,android,bar-chart,visualizer,Android,Bar Chart,Visualizer,我正在我的应用程序中使用visualizerView。我想知道怎样才能增加酒吧的高度 public class BarGraphRenderer extends Renderer { private int mDivisions; private Paint mPaint; private boolean mTop; /** * Renders the FFT data as a series of lines, in histogram form * @param

我正在我的应用程序中使用visualizerView。我想知道怎样才能增加酒吧的高度

public class BarGraphRenderer extends Renderer
{
  private int mDivisions;
  private Paint mPaint;
  private boolean mTop;

  /**
   * Renders the FFT data as a series of lines, in histogram form
   * @param divisions - must be a power of 2. Controls how many lines to draw
   * @param paint - Paint to draw lines with
   * @param top - whether to draw the lines at the top of the canvas, or the bottom
   */
  public BarGraphRenderer(int divisions,
                          Paint paint,
                          boolean top)
  {
    super();
    mDivisions = divisions;
    mPaint = paint;
    mTop = top;
  }

  @Override
  public void onRender(Canvas canvas, AudioData data, Rect rect)
  {
    // Do nothing, we only display FFT data
  }

  @Override
  public void onRender(Canvas canvas, FFTData data, Rect rect)
  {
    for (int i = 0; i < data.bytes.length / mDivisions; i++) {
      mFFTPoints[i * 4] = i * 4 * mDivisions;
      mFFTPoints[i * 4 + 2] = i * 4 * mDivisions;
      byte rfk = data.bytes[mDivisions * i];
      byte ifk = data.bytes[mDivisions * i + 1];
      float magnitude = (rfk * rfk + ifk * ifk);
      int dbValue = (int) (10 * Math.log10(magnitude));

      if(mTop)
      {
        mFFTPoints[i * 4 + 1] = 0;
        mFFTPoints[i * 4 + 3] = (dbValue * 2 - 10);
      }
      else
      {
        mFFTPoints[i * 4 + 1] = rect.height();
        mFFTPoints[i * 4 + 3] = rect.height() - (dbValue * 2 - 10);
      }
    }

    canvas.drawLines(mFFTPoints, mPaint);
  }
}
试试下面的代码

int size=3; 
if(mTop)
  {
    mFFTPoints[i * 4 + 1] = 0;
    mFFTPoints[i * 4 + 3] = (dbValue * size - 10);
  }
  else
  {
    mFFTPoints[i * 4 + 1] = rect.height();
    mFFTPoints[i * 4 + 3] = rect.height() - (dbValue * size - 10);
  }
}
您可以更改valuesize以增加可视化视图栏

这对我很有用

只需更改代码中的值10。到一个更大的值。我用了100,这对我来说很好。希望有帮助

int dbValue = (int) (10 * Math.log10(magnitude));

它增加了分区的大小,但改变了分区的数量。我尝试将顶部的尺寸设置为4,底部的尺寸设置为6。它会增加高度,但会更改分区数。