forked from lygttpod/AndroidCustomView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,631 additions
and
574 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
app/src/main/java/com/allen/androidcustomview/BubbleViewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package com.allen.androidcustomview; | ||
|
||
import android.graphics.PointF; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.allen.androidcustomview.bean.CircleBean; | ||
import com.allen.androidcustomview.utils.DisplayUtils; | ||
import com.allen.androidcustomview.widget.BubbleView; | ||
import com.allen.androidcustomview.widget.WaveViewByBezier; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BubbleViewActivity extends AppCompatActivity { | ||
|
||
private static final String TAG = "allen"; | ||
private ImageView hxbIv; | ||
private TextView hxbTv; | ||
private Button button; | ||
private BubbleView bezierView; | ||
|
||
private List<CircleBean> circleBeanList = new ArrayList<>(); | ||
|
||
private WaveViewByBezier waveView; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_bubble_view); | ||
waveView = (WaveViewByBezier) findViewById(R.id.wave); | ||
hxbIv = (ImageView) findViewById(R.id.hxb_iv); | ||
hxbTv = (TextView) findViewById(R.id.center_tv); | ||
bezierView = (BubbleView) findViewById(R.id.circle_view); | ||
button = (Button) findViewById(R.id.start_btn); | ||
button.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
bezierView.setCenterImg(hxbTv); | ||
bezierView.openAnimation(); | ||
|
||
} | ||
}); | ||
|
||
|
||
initPoint(); | ||
|
||
bezierView.setCircleBeen(circleBeanList); | ||
// bezierView.createInAnimation(); | ||
} | ||
|
||
private void initPoint() { | ||
|
||
int height = DisplayUtils.getDisplayHight(this); | ||
int width = DisplayUtils.getDisplayWidth(this); | ||
|
||
int centerX = width / 2; | ||
int centerY = height / 2; | ||
|
||
|
||
Log.d(TAG, "initPoint: " + centerX + "----" + centerY); | ||
|
||
|
||
CircleBean circleBean = new CircleBean( | ||
new PointF((float) (-width / 5.1), (float) (height / 1.5)), | ||
new PointF(centerX - 30, height * 2 / 3), | ||
new PointF((float) (width / 2.4), (float) (height / 3.4)), | ||
new PointF(width / 6, centerY - 120), | ||
new PointF((float) (width / 7.2), -height / 128), | ||
(float) (width / 14.4), 60); | ||
CircleBean circleBean2 = new CircleBean( | ||
new PointF(-width / 4, (float) (height / 1.3)), | ||
new PointF(centerX - 20, height * 3 / 5), | ||
new PointF((float) (width / 2.1), (float) (height / 2.5)), | ||
new PointF(width / 3, centerY - 10), | ||
new PointF(width / 4, (float) (-height / 5.3)), | ||
width / 4, 60); | ||
CircleBean circleBean3 = new CircleBean( | ||
new PointF(-width / 12, (float) (height / 1.1)), | ||
new PointF(centerX - 100, height * 2 / 3), | ||
new PointF((float) (width / 3.4), height / 2), | ||
new PointF(0, centerY + 100), | ||
new PointF(0, 0), | ||
width / 24, 60); | ||
|
||
CircleBean circleBean4 = new CircleBean( | ||
new PointF(-width / 9, (float) (height / 0.9)), | ||
new PointF(centerX, height * 3 / 4), | ||
new PointF((float) (width / 2.1), (float) (height / 2.3)), | ||
new PointF(width / 2, centerY), | ||
new PointF((float) (width / 1.5), (float) (-height / 5.6)), | ||
width / 4, 60); | ||
|
||
CircleBean circleBean5 = new CircleBean( | ||
new PointF((float) (width / 1.4), (float) (height / 0.9)), | ||
new PointF(centerX, height * 3 / 4), | ||
new PointF(width / 2, (float) (height / 2.37)), | ||
new PointF(width * 10 / 13, centerY - 20), | ||
new PointF(width / 2, (float) (-height / 7.1)), | ||
width / 4, 60); | ||
CircleBean circleBean6 = new CircleBean( | ||
new PointF((float) (width / 0.8), height), | ||
new PointF(centerX + 20, height * 2 / 3), | ||
new PointF((float) (width / 1.9), (float) (height / 2.3)), | ||
new PointF(width * 11 / 14, centerY + 10), | ||
|
||
new PointF((float) (width / 1.1), (float) (-height / 6.4)), | ||
(float) (width / 4), 60); | ||
CircleBean circleBean7 = new CircleBean( | ||
new PointF((float) (width / 0.9), (float) (height / 1.2)), | ||
new PointF(centerX + 20, height * 4 / 7), | ||
new PointF((float) (width / 1.6), (float) (height / 1.9)), | ||
new PointF(width, centerY + 10), | ||
|
||
new PointF(width, 0), | ||
(float) (width / 9.6), 60); | ||
|
||
circleBeanList.add(circleBean); | ||
circleBeanList.add(circleBean2); | ||
circleBeanList.add(circleBean3); | ||
circleBeanList.add(circleBean4); | ||
circleBeanList.add(circleBean5); | ||
circleBeanList.add(circleBean6); | ||
circleBeanList.add(circleBean7); | ||
|
||
} | ||
|
||
/** | ||
* 获取状态栏高度 | ||
* | ||
* @return | ||
*/ | ||
public int getStatusBarHeight() { | ||
int result = 0; | ||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); | ||
if (resourceId > 0) { | ||
result = getResources().getDimensionPixelSize(resourceId); | ||
} | ||
return result; | ||
} | ||
|
||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
Log.d(TAG, "onResume: "); | ||
waveView.startAnimation(); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
Log.d(TAG, "onPause: "); | ||
waveView.stopAnimation(); | ||
} | ||
} |
118 changes: 25 additions & 93 deletions
118
app/src/main/java/com/allen/androidcustomview/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,48 @@ | ||
package com.allen.androidcustomview; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import com.allen.androidcustomview.bean.CircleBean; | ||
import com.allen.androidcustomview.bean.Point; | ||
import com.allen.androidcustomview.utils.DisplayUtils; | ||
import com.allen.androidcustomview.widget.BezierView; | ||
import com.allen.androidcustomview.widget.WaveViewByBezier; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private static final String TAG = "allen"; | ||
private Button button; | ||
private BezierView bezierView; | ||
|
||
private List<CircleBean> circleBeanList = new ArrayList<>(); | ||
private Button button_bubble; | ||
private Button button_wave_bezier; | ||
private Button button_wave_sin_cos; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
bezierView = (BezierView) findViewById(R.id.circle_view); | ||
button = (Button) findViewById(R.id.start_btn); | ||
button.setOnClickListener(new View.OnClickListener() { | ||
|
||
button_bubble = (Button) findViewById(R.id.bubble_view_btn); | ||
button_wave_bezier = (Button) findViewById(R.id.wave_view_by_bezier_btn); | ||
button_wave_sin_cos = (Button) findViewById(R.id.wave_view_by_sin_cos_btn); | ||
|
||
button_bubble.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
bezierView.createInAnimation(); | ||
public void onClick(View view) { | ||
startActivity(new Intent(MainActivity.this, BubbleViewActivity.class)); | ||
} | ||
}); | ||
button_wave_bezier.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
startActivity(new Intent(MainActivity.this, WaveByBezierActivity.class)); | ||
} | ||
}); | ||
button_wave_sin_cos.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
startActivity(new Intent(MainActivity.this, WaveBySinCosActivity.class)); | ||
} | ||
}); | ||
|
||
initPoint(); | ||
|
||
bezierView.setCircleBeen(circleBeanList); | ||
// bezierView.createInAnimation(); | ||
} | ||
|
||
private void initPoint() { | ||
|
||
int hight = DisplayUtils.getDisplayHight(this); | ||
int width = DisplayUtils.getDisplayWidth(this); | ||
|
||
int centerX = width / 2; | ||
int centerY = hight / 3; | ||
|
||
Log.d(TAG, "initPoint: " + centerX + "----" + centerY); | ||
|
||
CircleBean circleBean = new CircleBean( | ||
new Point(-width / 4, hight * 3 / 5), | ||
new Point(centerX - 30, hight * 3 / 5), | ||
new Point(centerX - 30, centerY - 120), | ||
new Point(width / 6, centerY - 120), | ||
new Point(width / 6, 0), | ||
100, 60); | ||
CircleBean circleBean2 = new CircleBean( | ||
new Point(-width / 4, hight * 4 / 6), | ||
new Point(centerX - 20, hight * 4 / 6), | ||
new Point(centerX - 20, centerY - 10), | ||
new Point(width / 3, centerY - 10), | ||
new Point(width / 3, -hight * 5 / 27), | ||
130, 60); | ||
CircleBean circleBean3 = new CircleBean( | ||
new Point(-width / 12, hight * 5 / 7), | ||
new Point(centerX - 100, hight * 5 / 7), | ||
new Point(centerX - 100, centerY + 100), | ||
new Point(0, centerY + 100), | ||
new Point(0, 0), | ||
80, 60); | ||
|
||
CircleBean circleBean4 = new CircleBean( | ||
new Point(-width / 12, hight * 4 / 5), | ||
new Point(centerX, hight * 4 / 5), | ||
new Point(centerX, centerY), | ||
new Point(width / 2, centerY), | ||
new Point(width / 2, -hight / 7), | ||
200, 60); | ||
|
||
CircleBean circleBean5 = new CircleBean( | ||
new Point(width * 5 / 7, hight * 4 / 5), | ||
new Point(centerX, hight * 4 / 5), | ||
new Point(centerX, centerY - 20), | ||
new Point(width * 10 / 13, centerY - 20), | ||
new Point(width * 10 / 13, -hight * 2 / 13), | ||
260, 60); | ||
CircleBean circleBean6 = new CircleBean( | ||
new Point(width + width / 5, hight * 3 / 4), | ||
new Point(centerX + 20, hight * 3 / 4), | ||
new Point(centerX + 20, centerY + 10), | ||
new Point(width * 11 / 14, centerY + 10), | ||
|
||
new Point(width * 11 / 14, -hight * 5 / 27), | ||
70, 60); | ||
CircleBean circleBean7 = new CircleBean( | ||
new Point(width + width / 7, hight * 5 / 8), | ||
new Point(centerX + 20, hight * 5 / 8), | ||
new Point(centerX + 20, centerY + 10), | ||
new Point(width, centerY + 10), | ||
|
||
new Point(width, 0), | ||
100, 60); | ||
|
||
circleBeanList.add(circleBean); | ||
circleBeanList.add(circleBean2); | ||
circleBeanList.add(circleBean3); | ||
circleBeanList.add(circleBean4); | ||
circleBeanList.add(circleBean5); | ||
circleBeanList.add(circleBean6); | ||
circleBeanList.add(circleBean7); | ||
} | ||
} |
Oops, something went wrong.