Skip to content

Commit

Permalink
fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
JinJieGu committed Nov 9, 2017
1 parent 6a06f2b commit e96d29f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
android:id="@+id/waveLineView"
android:layout_width="match_parent"
android:layout_height="120dp"
app:wlvBackgroundColor="@android:color/transparent"
/>


Expand Down
19 changes: 17 additions & 2 deletions library/src/main/java/jaygoo/widget/wlv/WaveLineView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
import android.util.SparseArray;

Expand Down Expand Up @@ -97,6 +99,7 @@ public class WaveLineView extends RenderView {
//是否开启准备动画
private boolean isOpenPrepareAnim = false;

private boolean isTransparentMode = false;
public WaveLineView(Context context) {
this(context, null);
}
Expand All @@ -119,22 +122,34 @@ private void initAttr(AttributeSet attrs) {
fineLineWidth = (int)t.getDimension(R.styleable.WaveLineView_wlvFineLineWidth, 2);
offsetSpeed = t.getFloat(R.styleable.WaveLineView_wlvMoveSpeed, DEFAULT_OFFSET_SPEED);
sensibility = t.getInt(R.styleable.WaveLineView_wlvSensibility, DEFAULT_SENSIBILITY);
isTransparentMode = backGroundColor == Color.TRANSPARENT;
t.recycle();
checkVolumeValue();
checkSensibilityValue();
//将RenderView放到最顶层
setZOrderOnTop(true);
if (getHolder() != null) {
//使窗口支持透明度
getHolder().setFormat(PixelFormat.TRANSLUCENT);
}
}

@Override
protected void doDrawBackground(Canvas canvas) {
//绘制背景
canvas.drawColor(backGroundColor);
if (isTransparentMode) {
//启用CLEAR模式,所绘制内容不会提交到画布上。
canvas.drawColor(backGroundColor, PorterDuff.Mode.CLEAR);
}else {
canvas.drawColor(backGroundColor);
}
}

@Override
protected void onRender(Canvas canvas, long millisPassed) {
float offset = millisPassed / offsetSpeed;

if (null == samplingX){
if (null == samplingX || null == mapX || null == pathFuncs){
initDraw(canvas);
}

Expand Down

0 comments on commit e96d29f

Please sign in to comment.