|
5 | 5 | import android.util.Log; |
6 | 6 | import android.view.View; |
7 | 7 | import android.widget.Button; |
| 8 | +import android.widget.ImageView; |
| 9 | +import android.widget.TextView; |
8 | 10 |
|
9 | 11 | import com.allen.androidcustomview.bean.CircleBean; |
10 | 12 | import com.allen.androidcustomview.bean.Point; |
11 | 13 | import com.allen.androidcustomview.utils.DisplayUtils; |
12 | | -import com.allen.androidcustomview.widget.BezierView; |
| 14 | +import com.allen.androidcustomview.widget.BubbleView; |
13 | 15 |
|
14 | 16 | import java.util.ArrayList; |
15 | 17 | import java.util.List; |
16 | 18 |
|
17 | 19 | public class MainActivity extends AppCompatActivity { |
18 | 20 |
|
19 | 21 | private static final String TAG = "allen"; |
| 22 | + private ImageView hxbIv; |
| 23 | + private TextView hxbTv; |
20 | 24 | private Button button; |
21 | | - private BezierView bezierView; |
| 25 | + private BubbleView bezierView; |
22 | 26 |
|
23 | 27 | private List<CircleBean> circleBeanList = new ArrayList<>(); |
24 | 28 |
|
25 | 29 | @Override |
26 | 30 | protected void onCreate(Bundle savedInstanceState) { |
27 | 31 | super.onCreate(savedInstanceState); |
28 | 32 | setContentView(R.layout.activity_main); |
29 | | - bezierView = (BezierView) findViewById(R.id.circle_view); |
| 33 | + hxbIv = (ImageView) findViewById(R.id.hxb_iv); |
| 34 | + hxbTv = (TextView) findViewById(R.id.center_tv); |
| 35 | + bezierView = (BubbleView) findViewById(R.id.circle_view); |
30 | 36 | button = (Button) findViewById(R.id.start_btn); |
31 | 37 | button.setOnClickListener(new View.OnClickListener() { |
32 | 38 | @Override |
33 | 39 | public void onClick(View v) { |
34 | | - bezierView.createInAnimation(); |
| 40 | + bezierView.setCenterImg(hxbTv); |
| 41 | + bezierView.openAnimation(); |
35 | 42 | } |
36 | 43 | }); |
37 | 44 |
|
| 45 | + |
38 | 46 | initPoint(); |
39 | 47 |
|
40 | 48 | bezierView.setCircleBeen(circleBeanList); |
@@ -43,67 +51,68 @@ public void onClick(View v) { |
43 | 51 |
|
44 | 52 | private void initPoint() { |
45 | 53 |
|
46 | | - int hight = DisplayUtils.getDisplayHight(this); |
| 54 | + int height = DisplayUtils.getDisplayHight(this); |
47 | 55 | int width = DisplayUtils.getDisplayWidth(this); |
48 | 56 |
|
49 | 57 | int centerX = width / 2; |
50 | | - int centerY = hight / 3; |
| 58 | + int centerY = height / 2; |
51 | 59 |
|
52 | 60 | Log.d(TAG, "initPoint: " + centerX + "----" + centerY); |
53 | 61 |
|
| 62 | + |
54 | 63 | CircleBean circleBean = new CircleBean( |
55 | | - new Point(-width / 4, hight * 3 / 5), |
56 | | - new Point(centerX - 30, hight * 3 / 5), |
| 64 | + new Point(-width*5/21, height * 10/33), |
| 65 | + new Point(centerX - 30, height * 2 / 3), |
57 | 66 | new Point(centerX - 30, centerY - 120), |
58 | 67 | new Point(width / 6, centerY - 120), |
59 | 68 | new Point(width / 6, 0), |
60 | | - 100, 60); |
| 69 | + 84, 60); |
61 | 70 | CircleBean circleBean2 = new CircleBean( |
62 | | - new Point(-width / 4, hight * 4 / 6), |
63 | | - new Point(centerX - 20, hight * 4 / 6), |
| 71 | + new Point(-width / 4, height * 4 / 6), |
| 72 | + new Point(centerX - 20, height * 3 / 5), |
64 | 73 | new Point(centerX - 20, centerY - 10), |
65 | 74 | new Point(width / 3, centerY - 10), |
66 | | - new Point(width / 3, -hight * 5 / 27), |
67 | | - 130, 60); |
| 75 | + new Point(width / 3, -height * 5 / 27), |
| 76 | + 250, 60); |
68 | 77 | CircleBean circleBean3 = new CircleBean( |
69 | | - new Point(-width / 12, hight * 5 / 7), |
70 | | - new Point(centerX - 100, hight * 5 / 7), |
| 78 | + new Point(-width / 12, height * 5 / 7), |
| 79 | + new Point(centerX - 100, height * 2 / 3), |
71 | 80 | new Point(centerX - 100, centerY + 100), |
72 | 81 | new Point(0, centerY + 100), |
73 | 82 | new Point(0, 0), |
74 | | - 80, 60); |
| 83 | + 48, 60); |
75 | 84 |
|
76 | 85 | CircleBean circleBean4 = new CircleBean( |
77 | | - new Point(-width / 12, hight * 4 / 5), |
78 | | - new Point(centerX, hight * 4 / 5), |
| 86 | + new Point(-width / 12, height * 4 / 5), |
| 87 | + new Point(centerX, height * 3 / 4), |
79 | 88 | new Point(centerX, centerY), |
80 | 89 | new Point(width / 2, centerY), |
81 | | - new Point(width / 2, -hight / 7), |
82 | | - 200, 60); |
| 90 | + new Point(width / 2, -height / 7), |
| 91 | + 250, 60); |
83 | 92 |
|
84 | 93 | CircleBean circleBean5 = new CircleBean( |
85 | | - new Point(width * 5 / 7, hight * 4 / 5), |
86 | | - new Point(centerX, hight * 4 / 5), |
| 94 | + new Point(width * 5 / 7, height * 4 / 5), |
| 95 | + new Point(centerX, height * 3 / 4), |
87 | 96 | new Point(centerX, centerY - 20), |
88 | 97 | new Point(width * 10 / 13, centerY - 20), |
89 | | - new Point(width * 10 / 13, -hight * 2 / 13), |
90 | | - 260, 60); |
| 98 | + new Point(width * 10 / 13, -height * 2 / 13), |
| 99 | + 250, 60); |
91 | 100 | CircleBean circleBean6 = new CircleBean( |
92 | | - new Point(width + width / 5, hight * 3 / 4), |
93 | | - new Point(centerX + 20, hight * 3 / 4), |
| 101 | + new Point(width + width / 5, height * 3 / 4), |
| 102 | + new Point(centerX + 20, height * 2 / 3), |
94 | 103 | new Point(centerX + 20, centerY + 10), |
95 | 104 | new Point(width * 11 / 14, centerY + 10), |
96 | 105 |
|
97 | | - new Point(width * 11 / 14, -hight * 5 / 27), |
98 | | - 70, 60); |
| 106 | + new Point(width * 11 / 14, -height * 5 / 27), |
| 107 | + 250, 60); |
99 | 108 | CircleBean circleBean7 = new CircleBean( |
100 | | - new Point(width + width / 7, hight * 5 / 8), |
101 | | - new Point(centerX + 20, hight * 5 / 8), |
| 109 | + new Point(width + width / 7, height * 5 / 8), |
| 110 | + new Point(centerX + 20, height * 4 / 7), |
102 | 111 | new Point(centerX + 20, centerY + 10), |
103 | 112 | new Point(width, centerY + 10), |
104 | 113 |
|
105 | 114 | new Point(width, 0), |
106 | | - 100, 60); |
| 115 | + 120, 60); |
107 | 116 |
|
108 | 117 | circleBeanList.add(circleBean); |
109 | 118 | circleBeanList.add(circleBean2); |
@@ -112,5 +121,63 @@ private void initPoint() { |
112 | 121 | circleBeanList.add(circleBean5); |
113 | 122 | circleBeanList.add(circleBean6); |
114 | 123 | circleBeanList.add(circleBean7); |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | +// CircleBean circleBean = new CircleBean( |
| 129 | +// new Point(-width*5/21, height * 10/33), |
| 130 | +// new Point(centerX - 30, height * 3 / 5), |
| 131 | +// new Point(width*2/5, height/3), |
| 132 | +// new Point(width / 6, centerY - 120), |
| 133 | +// new Point(width / 6, 0), |
| 134 | +// 140, 60); |
| 135 | +// CircleBean circleBean2 = new CircleBean( |
| 136 | +// new Point(-width / 4, height * 4 / 6), |
| 137 | +// new Point(centerX - 20, height * 4 / 6), |
| 138 | +// new Point(centerX - 20, centerY - 10), |
| 139 | +// new Point(width / 3, centerY - 10), |
| 140 | +// new Point(width / 3, -height * 5 / 27), |
| 141 | +// 300, 60); |
| 142 | +// CircleBean circleBean3 = new CircleBean( |
| 143 | +// new Point(-width / 12, height * 5 / 7), |
| 144 | +// new Point(centerX - 100, height * 5 / 7), |
| 145 | +// new Point(centerX - 100, centerY + 100), |
| 146 | +// new Point(0, centerY + 100), |
| 147 | +// new Point(0, 0), |
| 148 | +// 300, 60); |
| 149 | +// |
| 150 | +// CircleBean circleBean4 = new CircleBean( |
| 151 | +// new Point(-width / 12, height * 4 / 5), |
| 152 | +// new Point(centerX, height * 4 / 5), |
| 153 | +// new Point(centerX, centerY), |
| 154 | +// new Point(width / 2, centerY), |
| 155 | +// new Point(width / 2, -height / 7), |
| 156 | +// 300, 60); |
| 157 | +// |
| 158 | +// CircleBean circleBean5 = new CircleBean( |
| 159 | +// new Point(width * 5 / 7, height * 4 / 5), |
| 160 | +// new Point(centerX, height * 4 / 5), |
| 161 | +// new Point(centerX, centerY - 20), |
| 162 | +// new Point(width * 10 / 13, centerY - 20), |
| 163 | +// new Point(width * 10 / 13, -height * 2 / 13), |
| 164 | +// 300, 60); |
| 165 | +// CircleBean circleBean6 = new CircleBean( |
| 166 | +// new Point(width + width / 5, height * 3 / 4), |
| 167 | +// new Point(centerX + 20, height * 3 / 4), |
| 168 | +// new Point(centerX + 20, centerY + 10), |
| 169 | +// new Point(width * 11 / 14, centerY + 10), |
| 170 | +// |
| 171 | +// new Point(width * 11 / 14, -height * 5 / 27), |
| 172 | +// 300, 60); |
| 173 | +// CircleBean circleBean7 = new CircleBean( |
| 174 | +// new Point(width + width / 7, height * 5 / 8), |
| 175 | +// new Point(centerX + 20, height * 5 / 8), |
| 176 | +// new Point(centerX + 20, centerY + 10), |
| 177 | +// new Point(width, centerY + 10), |
| 178 | +// |
| 179 | +// new Point(width, 0), |
| 180 | +// 180, 60); |
| 181 | + |
115 | 182 | } |
116 | 183 | } |