太极
来源:互联网 发布:量化投资数据挖掘 pdf 编辑:程序博客网 时间:2024/04/28 23:30
<?xml version="1.0" encoding="utf-8"?><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" > <fengras.com.taiji.view.TaiJiView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /></RelativeLayout>package fengras.com.taiji.view;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.RectF;import android.util.AttributeSet;import android.view.View;import android.view.animation.Animation;import android.view.animation.LinearInterpolator;import android.view.animation.RotateAnimation;public class TaiJiView extends View implements View.OnClickListener { private RotateAnimation rotateAnimation; private int width = 360; private int height = 360; private int padding = 5; private Paint mPaint; private RectF mRectf; private RectF blackHalfRect; private RectF whiteHalfRect; public TaiJiView(Context context) { this(context, null); } public TaiJiView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public TaiJiView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initPaint(); initAnim(); setOnClickListener(this); } /** * 初始化画笔 */ private void initPaint() { mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStrokeWidth(5); } private void initAnim() { //以view的中心点为旋转参考点 rotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setRepeatCount(-1); rotateAnimation.setFillAfter(false); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(width, height); mRectf = new RectF(0, 0, width, width); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); drawCirCle(canvas); drawHalfCirCle(canvas); drawSmallCircle(canvas); } /** * 绘制二个小圆点 * * @param canvas */ private void drawSmallCircle(Canvas canvas) { mPaint.setColor(Color.WHITE); mPaint.setStyle(Paint.Style.FILL); canvas.drawCircle(width / 2, width / 4, 20, mPaint); mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.FILL); canvas.drawCircle(width / 2, width / 4 * 3, 20, mPaint); } /** * 绘制二个半圆 一个黑色 一个白色 * * @param canvas */ private void drawHalfCirCle(Canvas canvas) { //画上面黑色半圆 mPaint.setStyle(Paint.Style.FILL); mPaint.setColor(Color.BLACK); blackHalfRect = new RectF(width / 4, 0, width / 2 + width / 4, width / 2); canvas.drawArc(blackHalfRect, 270, 180, true, mPaint); mPaint.setStyle(Paint.Style.FILL); mPaint.setColor(Color.WHITE); whiteHalfRect = new RectF(width / 4, width / 2, width / 2 + width / 4, width); canvas.drawArc(whiteHalfRect, 270, -180, true, mPaint); } /** * 画一个简单的圆 * * @param canvas */ private void drawCirCle(Canvas canvas) { mPaint.setStyle(Paint.Style.FILL); mPaint.setColor(Color.WHITE); canvas.drawArc(mRectf, 270, 180, true, mPaint); mPaint.setColor(Color.BLACK); canvas.drawArc(mRectf, 270, -180, true, mPaint); } @Override public void onClick(View view) { rotateAnimation.setDuration(1000); rotateAnimation.setInterpolator(new LinearInterpolator());//不停顿 startAnimation(rotateAnimation); }}
0 0
- 太极
- 太极
- 太极
- 太极
- 太极
- 一宙生太极
- 太极本末
- 太极一得
- 画太极
- 真太极《太极经解》
- 真太极 太极内篇
- 太极古镇 - 镇远
- 柔道与太极
- 程序员与太极
- 太极与管理
- 太极音乐下载
- flash 绘图API:太极
- SELECT与太极
- 第七周leetcode题
- poj 1322 概率dp
- appframework(2.1) 小技巧(更新中)
- RMAN兼容性、控制文件自动备份、保存时间、备份策略、备份脚本(二)
- to 群组 学习VUE建议
- 太极
- 51nod 活动安排问题之一
- HDU 1176 免费馅饼(普通dp
- ACM刷题之ZOJ————Demacia of the Ancients
- 基本图书馆管理表的创建和约束
- MySql中的索引
- 利用自动索引计算数组元素的平方和
- LeetCode 413. Arithmetic Slices
- 动态规划 03题