圆形头像设置Android 原代码
2015-09-09 15:01
447 查看
package com.xfej.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
public class CircleImageView extends BaseImageView {
public CircleImageView(Context context) {
super(context);
}
public CircleImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public static Bitmap getBitmap(int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.BLACK);
canvas.drawOval(new RectF(0.0f, 0.0f, width, height), paint);
return bitmap;
}
public Bitmap getBitmap() {
return getBitmap(getWidth(), getHeight());
}
}
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
public class CircleImageView extends BaseImageView {
public CircleImageView(Context context) {
super(context);
}
public CircleImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public static Bitmap getBitmap(int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.BLACK);
canvas.drawOval(new RectF(0.0f, 0.0f, width, height), paint);
return bitmap;
}
public Bitmap getBitmap() {
return getBitmap(getWidth(), getHeight());
}
}
相关文章推荐
- Android Handler简单使用
- Android短信息验证码自动填写详细介绍
- 日历算法Android
- Android学习——五种布局方式
- Android免Root无侵入AOP框架Dexposed
- android 权限大全
- Android免Root无侵入AOP框架Dexposed
- Mac 下安装使用Android Studio
- 【整理】Android中的USB中的UsbAccessory和UsbDevice的区别
- Android之自定义ContentProvider详解
- [Android Studio 权威教程]配置出“NB”的Android Studio
- Android 技术总结(004)—— ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法
- Android的onLayout、layout方法讲解
- android坐标
- Android第四十七期 - WheelView沉浸式菜单栏
- Android第四十七期 - WheelView沉浸式菜单栏
- Qt for android 界面适应
- 修改nexus 7的boot.img,打开系统调试
- Caused by: android.os.NetworkOnMainThreadException错误解决办法
- Android依赖注入应用