自定义App头像背景圆框
来源:互联网 发布:淘宝民族风女装品牌大全 编辑:程序博客网 时间:2024/04/30 07:49
import android.content.Context;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by JiaHua on 2016/4/14.
* 自定义view 圆
*/
public class RoundProgressBar extends View {
private int mRatio;
/** * view的宽度 */private int mWidth;/** * view的高度 */private int mHeight;/** * 圆弧的中心位置 */private int mArcCenterX;/** * 圆弧的中心位置 */private int mArcCenterY;/** * 外接矩形 */private RectF mArcRect;/** * 对应画笔的宽度 */private float mArcWidth;/** * 对应画笔的宽度 */private float mBarWidth;/** * 画笔 */private Paint mArcPaint;public RoundProgressBar(Context context) { super(context);}public RoundProgressBar(Context context, AttributeSet attrs) { super(context, attrs);}public RoundProgressBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr);}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int defaultWidth = Integer.MAX_VALUE; int width; int height; int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); if (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST) { width = widthSize; } else { width = defaultWidth; } int defaultHeight = (int) (width * 1.f / mRatio); height = defaultHeight; setMeasuredDimension(width, height);}@Overrideprotected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mWidth = w; mHeight = h; mArcCenterX = (int) (mWidth / 2.f); mArcCenterY = (int) (160.f / 525.f * mHeight); mArcRect = new RectF(); mArcRect.left = mArcCenterX - 125.f / 450.f * mWidth; mArcRect.top = mArcCenterY - 125.f / 525.f * mHeight; mArcRect.right = mArcCenterX + 125.f / 450.f * mWidth; mArcRect.bottom = mArcCenterY + 125.f / 525.f * mHeight; mArcWidth = 20.f / 450.f * mWidth; mBarWidth = 16.f / 450.f * mWidth;
// 画笔的宽度设置自适应
mArcPaint.setStrokeWidth(mArcWidth);
}
}
0 0
- 自定义App头像背景圆框
- 自定义View 应用于用户头像背景圆框
- 自定义圆头像
- 自定义实现圆头像
- 自定义圆头像
- Android APP头像的图标与背景的设置
- 自定义头像圆角控件
- 自定义圆形头像框二
- 自定义头像
- 画圆形背景头像
- 自定义imageview使头像变圆
- 给自定义圆头像加一个边
- Android 自定义圆角图片/头像
- 用户头像的背景为头像的模糊头像时候
- [仿南航app开发日记6]自定义背景透明进度条
- 自定义图片圆角背景
- 如何自定义虚线背景框
- Android自定义圆形头像
- onPrepareOptionsMenu 和onCreateOptionsMenu 的区别
- -Dmaven.multiModuleProjectDirectory system propery is not set.
- Linux下远程连接Jupyter+pyspark部署教程
- UI测试导入Espresso时的冲突
- Material Design: NavigationView FlaotingActionBar SnackBar的使用,navigationview
- 自定义App头像背景圆框
- Android PopupWindow 弹窗背景半透明,设置最大高度
- JS 终止执行的方法
- 目标检测“Exploit All the Layers: Fast and Accurate CNN Object Detector with Scale Dependent Pooling and”
- php之array_column 的使用
- springMVC工作原理
- vlc-android(1.9.1) 移到android studio
- 多线程调用单例类中的方法会不会造成线程安全问题
- apk打包的过程和原理