안 드 로 이 드 모방 위 챗 레이더 복사 검색 친구(논리 선명 실현 간단)

어느덧 이번 설 도 다 지 났 습 니 다.안 타 깝 게 도 집에 인터넷 이 없어 서 제때에 여러분 께 축복 을 드 리 지 못 했 습 니 다.오늘 심 천 으로 돌아 가면 내일 출근 해 야 합 니 다.친구 들 은 저 와 같 지 않 습 니까?오늘 은 모두 가 본 애니메이션 입 니 다.레이 더 는 친 구 를 검색 하 는 것 입 니 다.원리 도 매우 간단 합 니 다.제 분석 을 보면 간단 하 다 고 생각 할 것 입 니 다.국제 관례,진실 이 없습니다.우 리 는 먼저 효과 도 를 보 겠 습 니 다.참,정말 입 니 다.
테스트 기 가 사람 을 보 냈 습 니 다.그 동안 시 뮬 레이 터 로 계속 표시 해 야 겠 죠?
위 챗 레이더 스 캔 을 모방 하여 안 탁 위 챗,클 라 우 드 레이더 스 캔 애니메이션 효 과 를 모방 하여 중간 에 있 는 검은색 원 을 클릭 하여 애니메이션 을 스 캔 하기 시 작 했 습 니 다.다시 리 셋 을 클릭 하면 이런 효과 가 필요 한 친 구 는 스스로 다운로드 하여 볼 수 있 습 니 다.
효과 도 는 다음 과 같다.
这里写图片描述
이 화면 은 모두 가 알 고 있다 고 믿는다.우리 가 원 리 를 말 해 보 자.사실은 3 층 이다.
这里写图片描述
중간 에 한 장의 그림 이 있 고 그 다음 에 네 개의 원 을 그 려 야 합 니 다.이것 은 간단 하 겠 죠?아 닙 니 다.안 드 로 이 드 그래 픽 메커니즘(2)-사용자 정의 View 그래 픽,원형,삼각형,부채 형,타원,곡선,문자 와 그림 의 좌표 설명 을 볼 수 있 습 니 다.그리고 맨 위 에 그 라 데 이 션 원 이 있 습 니 다.이 원 은 우리 가 그 를 끊임없이 회전 시 키 기만 하면 됩 니 다.그럼 우 리 는 새로운 프로젝트 인 Radar Search 를 만 듭 시다.
这里写图片描述
layou_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/photo" >
<com.lgl.radarsearch.RadarView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/circle_photo" />
</RelativeLayout>
RadarView 를 새로 만 듭 니 다.

RadarView
package com.lgl.radarsearch;
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.Shader;
import android.graphics.SweepGradient;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
/**
*     
* 
* @author LGL
*
*/
public class RadarView extends View {
/**
*   :         ,          , onMeasure()     ,   onDraw()                ,
*     Matrix                     
*/
private Paint mPaintLine, mPaintCircle;
private int w, h;
//   
private Matrix matrix;
//     
private int start;
// Handler    
private Handler handler = new Handler();
private Runnable run = new Runnable() {
@Override
public void run() {
start = start + 1;
matrix = new Matrix();
//   :    ,      x,y   
matrix.postRotate(start, w / 2, h / 2);
//     
RadarView.this.invalidate();
//     
handler.postDelayed(run, 60);
}
};
public RadarView(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
//     
w = context.getResources().getDisplayMetrics().widthPixels;
h = context.getResources().getDisplayMetrics().heightPixels;
//     
handler.post(run);
}
private void initView() {
mPaintLine = new Paint();
mPaintLine.setColor(Color.WHITE);
mPaintLine.setAntiAlias(true);
mPaintLine.setStyle(Style.STROKE);
mPaintCircle = new Paint();
mPaintCircle.setColor(Color.RED);
mPaintCircle.setAntiAlias(true);
matrix = new Matrix();
}
/**
*   
* 
* @author LGL
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//     
setMeasuredDimension(w, h);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//      
canvas.drawCircle(w / 2, h / 2, w / 2, mPaintLine);
canvas.drawCircle(w / 2, h / 2, w / 3, mPaintLine);
canvas.drawCircle(w / 2, h / 2, w * 7 / 10, mPaintLine);
canvas.drawCircle(w / 2, h / 2, w / 4, mPaintLine);
//      
Shader mShader = new SweepGradient(w / 2, h / 2, Color.TRANSPARENT,
Color.parseColor("#AAAAAAAA"));
//      
mPaintCircle.setShader(mShader);
//       ,      
canvas.concat(matrix); //     
canvas.drawCircle(w / 2, h / 2, w * 7 / 10, mPaintCircle);
}
}
위 에서 말 한 것 은 소 편 이 소개 한 안 드 로 이 드 모방 위 챗 레이더 복사 검색 친구(논리 가 뚜렷 하고 간단 함)에 관 한 지식 으로 도움 이 되 기 를 바 랍 니 다.

좋은 웹페이지 즐겨찾기