• 大小: 874KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: Java
  • 标签: android  圆形图片  

资源简介

android圆形图片控件,在项目开发中,我们经常需要用到圆形图片效果,典型案例是用户头像的显示。

资源截图

代码片段和文件信息

/*
 * Copyright 2014 - 2019 Henning Dodenhof
 *
 * Licensed under the Apache License Version 2.0 (the “License“);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing software
 * distributed under the License is distributed on an “AS IS“ BASIS
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.hdodenhof.circleimageview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.RequiresApi;

@SuppressWarnings(“UnusedDeclaration“)
public class CircleImageView extends ImageView {

    private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;

    private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
    private static final int COLORDRAWABLE_DIMENSION = 2;

    private static final int DEFAULT_BORDER_WIDTH = 0;
    private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
    private static final int DEFAULT_CIRCLE_BACKGROUND_COLOR = Color.TRANSPARENT;
    private static final boolean DEFAULT_BORDER_OVERLAY = false;

    private final RectF mDrawableRect = new RectF();
    private final RectF mBorderRect = new RectF();

    private final Matrix mShaderMatrix = new Matrix();
    private final Paint mBitmapPaint = new Paint();
    private final Paint mBorderPaint = new Paint();
    private final Paint mCircleBackgroundPaint = new Paint();

    private int mBorderColor = DEFAULT_BORDER_COLOR;
    private int mBorderWidth = DEFAULT_BORDER_WIDTH;
    private int mCircleBackgroundColor = DEFAULT_CIRCLE_BACKGROUND_COLOR;

    private Bitmap mBitmap;
    private BitmapShader mBitmapShader;
    private int mBitmapWidth;
    private int mBitmapHeight;

    private float mDrawableRadius;
    private float mBorderRadius;

    private ColorFilter mColorFilter;

    private boolean mReady;
    private boolean mSetupPendi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-01-06 11:52  CircleImageView-master\
     文件         134  2019-01-06 11:52  CircleImageView-master\.gitignore
     文件       11359  2019-01-06 11:52  CircleImageView-master\LICENSE.txt
     文件        5261  2019-01-06 11:52  CircleImageView-master\README.md
     文件         281  2019-01-06 11:52  CircleImageView-master\build.gradle
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\
     文件         350  2019-01-06 11:52  CircleImageView-master\circleimageview\build.gradle
     文件          74  2019-01-06 11:52  CircleImageView-master\circleimageview\gradle.properties
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\
     文件         185  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\AndroidManifest.xml
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\java\
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\java\de\
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\java\de\hdodenhof\
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\java\de\hdodenhof\circleimageview\
     文件       13477  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\java\de\hdodenhof\circleimageview\CircleImageView.java
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\res\
     目录           0  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\res\values\
     文件         379  2019-01-06 11:52  CircleImageView-master\circleimageview\src\main\res\values\attrs.xml
     文件         613  2019-01-06 11:52  CircleImageView-master\gradle.properties
     目录           0  2019-01-06 11:52  CircleImageView-master\gradle\
     目录           0  2019-01-06 11:52  CircleImageView-master\gradle\wrapper\
     文件       50508  2019-01-06 11:52  CircleImageView-master\gradle\wrapper\gradle-wrapper.jar
     文件         231  2019-01-06 11:52  CircleImageView-master\gradle\wrapper\gradle-wrapper.properties
     文件        5080  2019-01-06 11:52  CircleImageView-master\gradlew
     文件        2404  2019-01-06 11:52  CircleImageView-master\gradlew.bat
     目录           0  2019-01-06 11:52  CircleImageView-master\sample\
     文件         253  2019-01-06 11:52  CircleImageView-master\sample\build.gradle
     文件         670  2019-01-06 11:52  CircleImageView-master\sample\proguard-rules.txt
     目录           0  2019-01-06 11:52  CircleImageView-master\sample\src\
     目录           0  2019-01-06 11:52  CircleImageView-master\sample\src\main\
............此处省略27个文件信息

评论

共有 条评论