防微信雷達掃描加好友控制元件實現
效果圖如下:
RadarView.java
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.SweepGradient;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class RadarView extends FrameLayout {
private int w, h;
private Matrix matrix;
private Paint mPaintLine;// 畫普通圓和線的畫筆
private Paint mPaintSector;// 畫有漸變效果的圓的畫筆
public boolean isstart = false;
private int start;
private Handler handler = new Handler();
private Runnable run = new Runnable() {
public void run() {
// TODO Auto-generated method stub
start = start + 1;
matrix = new Matrix();
matrix.postRotate(start, w / 2, h / 2);
RadarView.this.invalidate();
handler.postDelayed(run, 50);
}
};
public RadarView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
initPaint();
setBackgroundResource(R.drawable.a1v);
w = context.getResources().getDisplayMetrics().widthPixels;
h = context.getResources().getDisplayMetrics().heightPixels;
handler.post(run);
}
private void initPaint() {
// TODO Auto-generated method stub
mPaintLine = new Paint();
mPaintLine.setColor(Color.parseColor("#A1A1A1"));
mPaintLine.setStrokeWidth(3);
mPaintLine.setAntiAlias(true);
mPaintLine.setStyle(Style.STROKE);
mPaintSector = new Paint();
mPaintSector.setColor(0x9D00ff00);
mPaintSector.setAntiAlias(true);
matrix = new Matrix();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
setMeasuredDimension(w, h);
}
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
canvas.drawCircle(w / 2, h / 2, w / 6, mPaintLine);// 小圓
canvas.drawCircle(w / 2, h / 2, 2 * w / 6, mPaintLine);// 中圓
canvas.drawCircle(w / 2, h / 2, 11 * w / 20, mPaintLine);
canvas.drawCircle(w / 2, h / 2, 7 * h / 16, mPaintLine);// 大圓
SweepGradient mShader = new SweepGradient(w / 2, h / 2,
Color.TRANSPARENT, Color.parseColor("#AAAAAAAA"));
mPaintSector.setShader(mShader);
canvas.concat(matrix);
canvas.drawCircle(w / 2, h / 2, 7 * h / 16, mPaintSector);
super.onDraw(canvas);
}
}
activity:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
public class CustomerRadarViewActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer_radar_view);
}
public void quit(View v){
finish();
}
}
佈局檔案:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.tz.dream.customer.view.RadarView
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="@drawable/girl" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="30dp"
android:layout_marginLeft="5dp"
android:background="@drawable/back_selector"
android:paddingBottom="3dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="3dp"
android:text="退出"
android:textColor="#A1A1A1"
android:onClick="quit"/>
</FrameLayout>
整理自原始碼
相關文章
- CSS3雷達掃描效果CSSS3
- Android自定義View 雷達掃描效果AndroidView
- 自定義View 實現多塔機監控類似星軌雷達掃描View
- JS實現掃雷JS
- 掃雷--C語言實現C語言
- go語言實現掃雷Go
- canvas 實現雷達圖Canvas
- Go 實現埠掃描器Go
- GO語言 實現埠掃描Go
- Python 實現埠掃描器Python
- TWAIN掃描識別控制元件:Web應用程式的掃描器SDKAI控制元件Web
- 探秘掃雷遊戲的C語言實現遊戲C語言
- 安全科普:Waf實現掃描器識別 徹底抵擋駭客掃描
- Python自動掃描出微信不是好友名單Python
- Android實現掃描二維碼Android
- SCAN掃描演算法 java實現演算法Java
- 主機掃描程式實現方法 (轉)
- 掃描儲存上的新加空間
- React Native 實現二維碼掃描React Native
- 京東掃描平臺EOS—JS掃描落地與實踐JS
- Python3+pygame實現Windows經典掃雷PythonGAMWindows
- 利用Python實現自動掃雷小指令碼Python指令碼
- vb.net使用GDI+實現掃雷小遊戲遊戲
- 掃描技術和掃描工具
- 一個炫酷的仿雷達掃描和擴散效果——自定義View就是這麼簡單View
- 用Python實現圖片的清晰掃描Python
- Java 實現OCR掃描/識別圖片文字Java
- Python + Wxpy 實現微信防撤回。Python
- GetX 實現類似微信轉發搜尋多選好友
- 用 ABAP 呼叫 OCR 介面實現計程車發票掃描
- 如此簡單遠端漏洞掃描實現雲安全
- Linux系統中掃描、列印的實現(轉)Linux
- AWVS掃描器掃描web漏洞操作Web
- win10系統掃描器提示掃描不到掃描器如何解決Win10
- 掃描王 for Mac專業圖片掃描工具Mac
- Nmap掃描教程之基礎掃描詳解
- 【matplotlib 實戰】--雷達圖
- 自動掃雷程式