防微信雷达扫描加好友控件实现

效果图如下:



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>

整理自源代码

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]中的代码是一个使用Python实现微信好友的示例代码。这段代码使用了wxpy库来实现微信机器人的功能。首先,通过创建一个机器人对象(bot)并启用缓存功能和二维码登录方式。然后,通过bot.groups().search('Goodog')来搜索需要入的群。接下来,定义了一个自动通过好友请求的函数,并在函数中发送群提示信息。另外,还定义了一个关键字回复函数,当收到包含关键字的消息时,将邀请用户入指定的群。最后,还定义了一个函数用于在用户入群后发送群公告。这段代码实现了自动通过好友请求并发送群邀请链接的功能。引用\[2\]和\[3\]提到了管理大量微信社群时的场景,当微信群的人数达到100人之后,无法通过分享的群二维码入群,需要手动邀请好友入。因此,使用Python实现微信好友的功能可以提高效率,避免手动邀请的繁琐过程。 #### 引用[.reference_title] - *1* *3* [Python 实现微信自动通过好友请求!!!](https://blog.csdn.net/qq_17481731/article/details/103084753)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Python实现微信自动通过好友申请并发送群链接!](https://blog.csdn.net/weixin_39612058/article/details/110447994)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值