Android 完美实现图片圆角和圆形

简介:

本来想在网上找个圆角的例子看一看,不尽人意啊,基本都是官方的Demo的那张原理图,稍后会贴出。于是自己自定义了个View,实现图片的圆角以及圆形效果。效果图:


好了,原理和核心代码解释完成。下面开始写自定义View。

1、自定义属性:

第一个是原图,第二个是圆形效果,第三第四设置了不同的圆角大小。

准备改变一个博客的风格,首先给大家讲一下原理,让大家明白了,然后再贴代码,不然可以直接看那么长的代码也比较痛苦,核心代码其实就那么几行:

核心代码分析:

 

  1. /** 

  2.      * 绘制 

  3.      */  

  4.     @Override  

  5.     protected void onDraw(Canvas canvas)  

  6.     {  

  7.   

  8.         switch (type)  

  9.         {  

  10.         // 如果是TYPE_CIRCLE绘制圆形  

  11.         case TYPE_CIRCLE:  

  12.   

  13.             int min = Math.min(mWidth, mHeight);  

  14.             /** 

  15.              * 长度如果不一致,按小的值进行压缩 

  16.              */  

  17.             mSrc = Bitmap.createScaledBitmap(mSrc, min, min, false);  

  18.   

  19.             canvas.drawBitmap(createCircleImage(mSrc, min), 0, 0, null);  

  20.             break;  

  21.         case TYPE_ROUND:  

  22.             canvas.drawBitmap(createRoundConerImage(mSrc), 0, 0, null);  

  23.             break;  

  24.   

  25.         }  

  26.   

  27.     }  

  28.   

  29.     /** 

  30.      * 根据原图和变长绘制圆形图片 

  31.      *  

  32.      * @param source 

  33.      * @param min 

  34.      * @return 

  35.      */  

  36.     private Bitmap createCircleImage(Bitmap source, int min)  

  37.     {  

  38.         final Paint paint = new Paint();  

  39.         paint.setAntiAlias(true);  

  40.         Bitmap target = Bitmap.createBitmap(min, min, Config.ARGB_8888);  

  41.         /** 

  42.          * 产生一个同样大小的画布 

  43.          */  

  44.         Canvas canvas = new Canvas(target);  

  45.         /** 

  46.          * 首先绘制圆形 

  47.          */  

  48.         canvas.drawCircle(min / 2, min / 2, min / 2, paint);  

  49.         /** 

  50.          * 使用SRC_IN,参考上面的说明 

  51.          */  

  52.         paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));  

  53.         /** 

  54.          * 绘制图片 

  55.          */  

  56.         canvas.drawBitmap(source, 0, 0, paint);  

  57.         return target;  

  58.     }  

  59.   

  60.     /** 

  61.      * 根据原图添加圆角 

  62.      *  

  63.      * @param source 

  64.      * @return 

  65.      */  

  66.     private Bitmap createRoundConerImage(Bitmap source)  

  67.     {  

  68.         final Paint paint = new Paint();  

  69.         paint.setAntiAlias(true);  

  70.         Bitmap target = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);  

  71.         Canvas canvas = new Canvas(target);  

  72.         RectF rect = new RectF(0, 0, source.getWidth(), source.getHeight());  

  73.         canvas.drawRoundRect(rect, mRadius, mRadius, paint);  

  74.         paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));  

  75.         canvas.drawBitmap(source, 0, 0, paint);  

  76.         return target;  

  77.     }  

 

 

 

 

 

 

  1. /** 

  2.      * 计算控件的高度和宽度 

  3.      */  

  4.     @Override  

  5.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)  

  6.     {  

  7.         // super.onMeasure(widthMeasureSpec, heightMeasureSpec);  

  8.         /** 

  9.          * 设置宽度 

  10.          */  

  11.         int specMode = MeasureSpec.getMode(widthMeasureSpec);  

  12.         int specSize = MeasureSpec.getSize(widthMeasureSpec);  

  13.   

  14.         if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate  

  15.         {  

  16.             mWidth = specSize;  

  17.         } else  

  18.         {  

  19.             // 由图片决定的宽  

  20.             int desireByImg = getPaddingLeft() + getPaddingRight()  

  21.                     + mSrc.getWidth();  

  22.             if (specMode == MeasureSpec.AT_MOST)// wrap_content  

  23.             {  

  24.                 mWidth = Math.min(desireByImg, specSize);  

  25.             } else  

  26.   

  27.                 mWidth = desireByImg;  

  28.         }  

  29.   

  30.         /*** 

  31.          * 设置高度 

  32.          */  

  33.   

  34.         specMode = MeasureSpec.getMode(heightMeasureSpec);  

  35.         specSize = MeasureSpec.getSize(heightMeasureSpec);  

  36.         if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate  

  37.         {  

  38.             mHeight = specSize;  

  39.         } else  

  40.         {  

  41.             int desire = getPaddingTop() + getPaddingBottom()  

  42.                     + mSrc.getHeight();  

  43.   

  44.             if (specMode == MeasureSpec.AT_MOST)// wrap_content  

  45.             {  

  46.                 mHeight = Math.min(desire, specSize);  

  47.             } else  

  48.                 mHeight = desire;  

  49.         }  

  50.   

  51.         setMeasuredDimension(mWidth, mHeight);  

  52.   

  53.     }  

 

4、根据Type绘制:

 

[java] view plain copy


  在CODE上查看代码片 派生到我的代码片

 

  1. /** 

  2.  * TYPE_CIRCLE / TYPE_ROUND 

  3.  */  

  4. private int type;  

  5. private static final int TYPE_CIRCLE = 0;  

  6. private static final int TYPE_ROUND = 1;  

  7.   

  8. /** 

  9.  * 图片 

  10.  */  

  11. private Bitmap mSrc;  

  12.   

  13. /** 

  14.  * 圆角的大小 

  15.  */  

  16. private int mRadius;  

  17.   

  18. /** 

  19.  * 控件的宽度 

  20.  */  

  21. private int mWidth;  

  22. /** 

  23.  * 控件的高度 

  24.  */  

  25. private int mHeight;  

  26.   

  27. public CustomImageView(Context context, AttributeSet attrs)  

  28. {  

  29.     this(context, attrs, 0);  

  30. }  

  31.   

  32. public CustomImageView(Context context)  

  33. {  

  34.     this(context, null);  

  35. }  

  36.   

  37. /** 

  38.  * 初始化一些自定义的参数 

  39.  *  

  40.  * @param context 

  41.  * @param attrs 

  42.  * @param defStyle 

  43.  */  

  44. public CustomImageView(Context context, AttributeSet attrs, int defStyle)  

  45. {  

  46.     super(context, attrs, defStyle);  

  47.   

  48.     TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomImageView, defStyle, 0);  

  49.   

  50.     int n = a.getIndexCount();  

  51.     for (int i = 0; i < n; i++)  

  52.     {  

  53.         int attr = a.getIndex(i);  

  54.         switch (attr)  

  55.         {  

  56.         case R.styleable.CustomImageView_src:  

  57.             mSrc = BitmapFactory.decodeResource(getResources(), a.getResourceId(attr, 0));  

  58.             break;  

  59.         case R.styleable.CustomImageView_type:  

  60.             type = a.getInt(attr, 0);// 默认为Circle  

  61.             break;  

  62.         case R.styleable.CustomImageView_borderRadius:  

  63.             mRadius= a.getDimensionPixelSize(attr, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f,  

  64.                     getResources().getDisplayMetrics()));// 默认为10DP  

  65.             break;  

  66.         }  

  67.     }  

  68.     a.recycle();  

  69. }  

3、onMeasure中获取控件宽高:

 

[java] view plain copy

 

  1. <?xml version="1.0" encoding="utf-8"?>  

  2. <resources>  

  3.   

  4.     <attr name="borderRadius" format="dimension" />  

  5.     <attr name="type">  

  6.         <enum name="circle" value="0" />  

  7.         <enum name="round" value="1" />  

  8.     </attr>  

  9.     <attr name="src" format="reference"></attr>  

  10.   

  11.     <declare-styleable name="CustomImageView">  

  12.         <attr name="borderRadius" />  

  13.         <attr name="type" />  

  14.         <attr name="src" />  

  15.     </declare-styleable>  

  16.   

  17. </resources>  


2、构造中获取自定义的属性:

[java] view plain copy

  在CODE上查看代码片 派生到我的代码片

 

  1. canvas.translate(x, y);  

  2.               canvas.drawBitmap(mDstB, 0, 0, paint);  

  3.               paint.setXfermode(sModes[i]);  

  4.               canvas.drawBitmap(mSrcB, 0, 0, paint);  

  5.               paint.setXfermode(null);  

  6.               canvas.restoreToCount(sc);  

可以看出先绘制的Dst,再绘制的Src,最后的展示是SrcIn那个图:显示的区域是二者交集,展示的是Src(后者)。和咱们前面结论一致。效果16种,大家可以自由组合展示不同的效果。

 

 

好了,原理和核心代码解释完成。下面开始写自定义View。

1、自定义属性:

 

[html] view plain copy

  在CODE上查看代码片 派生到我的代码片

 

  1. /** 

  2.      * 根据原图和变长绘制圆形图片 

  3.      *  

  4.      * @param source 

  5.      * @param min 

  6.      * @return 

  7.      */  

  8.     private Bitmap createCircleImage(Bitmap source, int min)  

  9.     {  

  10.         final Paint paint = new Paint();  

  11.         paint.setAntiAlias(true);  

  12.         Bitmap target = Bitmap.createBitmap(min, min, Config.ARGB_8888);  

  13.         /** 

  14.          * 产生一个同样大小的画布 

  15.          */  

  16.         Canvas canvas = new Canvas(target);  

  17.         /** 

  18.          * 首先绘制圆形 

  19.          */  

  20.         canvas.drawCircle(min / 2, min / 2, min / 2, paint);  

  21.         /** 

  22.          * 使用SRC_IN 

  23.          */  

  24.         paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));  

  25.         /** 

  26.          * 绘制图片 

  27.          */  

  28.         canvas.drawBitmap(source, 0, 0, paint);  

  29.         return target;  

  30.     }  


其实主要靠:paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));这行代码,为什么呢,我给大家解释下,SRC_IN这种模式,两个绘制的效果叠加后取交集展现后图,怎么说呢,咱们第一个绘制的是个圆形,第二个绘制的是个Bitmap,于是交集为圆形,展现的是BItmap,就实现了圆形图片效果。圆角,其实就是先绘制圆角矩形,是不是很简单,以后别人再说实现圆角,你就把这一行代码给他就行了。

 

从Android的示例中,给大家证明一下:

下面有一张PorterDuff.Mode的16中效果图,咱们的只是其一:


源码咱们只关心谁先谁后绘制的:

 

  1. canvas.translate(x, y);  

  2.               canvas.drawBitmap(mDstB, 0, 0, paint);  

  3.               paint.setXfermode(sModes[i]);  

  4.               canvas.drawBitmap(mSrcB, 0, 0, paint);  

  5.               paint.setXfermode(null);  

  6.               canvas.restoreToCount(sc);  

 可以看出先绘制的Dst,再绘制的Src,最后的展示是SrcIn那个图:显示的区域是二者交集,展示的是Src(后者)。和咱们前面结论一致。效果16种,大家可以自由组合展示不同的效果。

  1. <?xml version="1.0" encoding="utf-8"?>  

  2. <resources>  

  3.   

  4.     <attr name="borderRadius" format="dimension" />  

  5.     <attr name="type">  

  6.         <enum name="circle" value="0" />  

  7.         <enum name="round" value="1" />  

  8.     </attr>  

  9.     <attr name="src" format="reference"></attr>  

  10.   

  11.     <declare-styleable name="CustomImageView">  

  12.         <attr name="borderRadius" />  

  13.         <attr name="type" />  

  14.         <attr name="src" />  

  15.     </declare-styleable>  

  16.   

  17. </resources>  

 2、构造中获取自定义的属性:

 

  1. /** 

  2.  * TYPE_CIRCLE / TYPE_ROUND 

  3.  */  

  4. private int type;  

  5. private static final int TYPE_CIRCLE = 0;  

  6. private static final int TYPE_ROUND = 1;  

  7.   

  8. /** 

  9.  * 图片 

  10.  */  

  11. private Bitmap mSrc;  

  12.   

  13. /** 

  14.  * 圆角的大小 

  15.  */  

  16. private int mRadius;  

  17.   

  18. /** 

  19.  * 控件的宽度 

  20.  */  

  21. private int mWidth;  

  22. /** 

  23.  * 控件的高度 

  24.  */  

  25. private int mHeight;  

  26.   

  27. public CustomImageView(Context context, AttributeSet attrs)  

  28. {  

  29.     this(context, attrs, 0);  

  30. }  

  31.   

  32. public CustomImageView(Context context)  

  33. {  

  34.     this(context, null);  

  35. }  

  36.   

  37. /** 

  38.  * 初始化一些自定义的参数 

  39.  *  

  40.  * @param context 

  41.  * @param attrs 

  42.  * @param defStyle 

  43.  */  

  44. public CustomImageView(Context context, AttributeSet attrs, int defStyle)  

  45. {  

  46.     super(context, attrs, defStyle);  

  47.   

  48.     TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomImageView, defStyle, 0);  

  49.   

  50.     int n = a.getIndexCount();  

  51.     for (int i = 0; i < n; i++)  

  52.     {  

  53.         int attr = a.getIndex(i);  

  54.         switch (attr)  

  55.         {  

  56.         case R.styleable.CustomImageView_src:  

  57.             mSrc = BitmapFactory.decodeResource(getResources(), a.getResourceId(attr, 0));  

  58.             break;  

  59.         case R.styleable.CustomImageView_type:  

  60.             type = a.getInt(attr, 0);// 默认为Circle  

  61.             break;  

  62.         case R.styleable.CustomImageView_borderRadius:  

  63.             mRadius= a.getDimensionPixelSize(attr, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f,  

  64.                     getResources().getDisplayMetrics()));// 默认为10DP  

  65.             break;  

  66.         }  

  67.     }  

  68.     a.recycle();  

  69. }  

  70. 2.构造中获取自定义属性:

 

  1. /** 

  2.  * TYPE_CIRCLE / TYPE_ROUND 

  3.  */  

  4. private int type;  

  5. private static final int TYPE_CIRCLE = 0;  

  6. private static final int TYPE_ROUND = 1;  

  7.   

  8. /** 

  9.  * 图片 

  10.  */  

  11. private Bitmap mSrc;  

  12.   

  13. /** 

  14.  * 圆角的大小 

  15.  */  

  16. private int mRadius;  

  17.   

  18. /** 

  19.  * 控件的宽度 

  20.  */  

  21. private int mWidth;  

  22. /** 

  23.  * 控件的高度 

  24.  */  

  25. private int mHeight;  

  26.   

  27. public CustomImageView(Context context, AttributeSet attrs)  

  28. {  

  29.     this(context, attrs, 0);  

  30. }  

  31.   

  32. public CustomImageView(Context context)  

  33. {  

  34.     this(context, null);  

  35. }  

  36.   

  37. /** 

  38.  * 初始化一些自定义的参数 

  39.  *  

  40.  * @param context 

  41.  * @param attrs 

  42.  * @param defStyle 

  43.  */  

  44. public CustomImageView(Context context, AttributeSet attrs, int defStyle)  

  45. {  

  46.     super(context, attrs, defStyle);  

  47.   

  48.     TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomImageView, defStyle, 0);  

  49.   

  50.     int n = a.getIndexCount();  

  51.     for (int i = 0; i < n; i++)  

  52.     {  

  53.         int attr = a.getIndex(i);  

  54.         switch (attr)  

  55.         {  

  56.         case R.styleable.CustomImageView_src:  

  57.             mSrc = BitmapFactory.decodeResource(getResources(), a.getResourceId(attr, 0));  

  58.             break;  

  59.         case R.styleable.CustomImageView_type:  

  60.             type = a.getInt(attr, 0);// 默认为Circle  

  61.             break;  

  62.         case R.styleable.CustomImageView_borderRadius:  

  63.             mRadius= a.getDimensionPixelSize(attr, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f,  

  64.                     getResources().getDisplayMetrics()));// 默认为10DP  

  65.             break;  

  66.         }  

  67.     }  

  68.     a.recycle();  

  69. }  

    3、onMeasure中获取控件宽高:

 

  1. /** 

  2.      * 计算控件的高度和宽度 

  3.      */  

  4.     @Override  

  5.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)  

  6.     {  

  7.         // super.onMeasure(widthMeasureSpec, heightMeasureSpec);  

  8.         /** 

  9.          * 设置宽度 

  10.          */  

  11.         int specMode = MeasureSpec.getMode(widthMeasureSpec);  

  12.         int specSize = MeasureSpec.getSize(widthMeasureSpec);  

  13.   

  14.         if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate  

  15.         {  

  16.             mWidth = specSize;  

  17.         } else  

  18.         {  

  19.             // 由图片决定的宽  

  20.             int desireByImg = getPaddingLeft() + getPaddingRight()  

  21.                     + mSrc.getWidth();  

  22.             if (specMode == MeasureSpec.AT_MOST)// wrap_content  

  23.             {  

  24.                 mWidth = Math.min(desireByImg, specSize);  

  25.             } else  

  26.   

  27.                 mWidth = desireByImg;  

  28.         }  

  29.   

  30.         /*** 

  31.          * 设置高度 

  32.          */  

  33.   

  34.         specMode = MeasureSpec.getMode(heightMeasureSpec);  

  35.         specSize = MeasureSpec.getSize(heightMeasureSpec);  

  36.         if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate  

  37.         {  

  38.             mHeight = specSize;  

  39.         } else  

  40.         {  

  41.             int desire = getPaddingTop() + getPaddingBottom()  

  42.                     + mSrc.getHeight();  

  43.   

  44.             if (specMode == MeasureSpec.AT_MOST)// wrap_content  

  45.             {  

  46.                 mHeight = Math.min(desire, specSize);  

  47.             } else  

  48.                 mHeight = desire;  

  49.         }  

  50.   

  51.         setMeasuredDimension(mWidth, mHeight);  

  52.   

  53.     }  

4、根据Type绘制:

 

  1. /** 

  2.      * 绘制 

  3.      */  

  4.     @Override  

  5.     protected void onDraw(Canvas canvas)  

  6.     {  

  7.   

  8.         switch (type)  

  9.         {  

  10.         // 如果是TYPE_CIRCLE绘制圆形  

  11.         case TYPE_CIRCLE:  

  12.   

  13.             int min = Math.min(mWidth, mHeight);  

  14.             /** 

  15.              * 长度如果不一致,按小的值进行压缩 

  16.              */  

  17.             mSrc = Bitmap.createScaledBitmap(mSrc, min, min, false);  

  18.   

  19.             canvas.drawBitmap(createCircleImage(mSrc, min), 0, 0, null);  

  20.             break;  

  21.         case TYPE_ROUND:  

  22.             canvas.drawBitmap(createRoundConerImage(mSrc), 0, 0, null);  

  23.             break;  

  24.   

  25.         }  

  26.   

  27.     }  

  28.   

  29.     /** 

  30.      * 根据原图和变长绘制圆形图片 

  31.      *  

  32.      * @param source 

  33.      * @param min 

  34.      * @return 

  35.      */  

  36.     private Bitmap createCircleImage(Bitmap source, int min)  

  37.     {  

  38.         final Paint paint = new Paint();  

  39.         paint.setAntiAlias(true);  

  40.         Bitmap target = Bitmap.createBitmap(min, min, Config.ARGB_8888);  

  41.         /** 

  42.          * 产生一个同样大小的画布 

  43.          */  

  44.         Canvas canvas = new Canvas(target);  

  45.         /** 

  46.          * 首先绘制圆形 

  47.          */  

  48.         canvas.drawCircle(min / 2, min / 2, min / 2, paint);  

  49.         /** 

  50.          * 使用SRC_IN,参考上面的说明 

  51.          */  

  52.         paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));  

  53.         /** 

  54.          * 绘制图片 

  55.          */  

  56.         canvas.drawBitmap(source, 0, 0, paint);  

  57.         return target;  

  58.     }  

  59.   

  60.     /** 

  61.      * 根据原图添加圆角 

  62.      *  

  63.      * @param source 

  64.      * @return 

  65.      */  

  66.     private Bitmap createRoundConerImage(Bitmap source)  

  67.     {  

  68.         final Paint paint = new Paint();  

  69.         paint.setAntiAlias(true);  

  70.         Bitmap target = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);  

  71.         Canvas canvas = new Canvas(target);  

  72.         RectF rect = new RectF(0, 0, source.getWidth(), source.getHeight());  

  73.         canvas.drawRoundRect(rect, mRadius, mRadius, paint);  

  74.         paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));  

  75.         canvas.drawBitmap(source, 0, 0, paint);  

  76.         return target;  

  77.     }  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 本文转自 linuxpp 51CTO博客,原文链接:http://blog.51cto.com/1439337369/1834342,如需转载请自行联系原作者

相关文章
|
5月前
|
存储 缓存 编解码
Android经典面试题之图片Bitmap怎么做优化
本文介绍了图片相关的内存优化方法,包括分辨率适配、图片压缩与缓存。文中详细讲解了如何根据不同分辨率放置图片资源,避免图片拉伸变形;并通过示例代码展示了使用`BitmapFactory.Options`进行图片压缩的具体步骤。此外,还介绍了Glide等第三方库如何利用LRU算法实现高效图片缓存。
94 20
Android经典面试题之图片Bitmap怎么做优化
|
9月前
|
Android开发
Android通过手势(多点)缩放和拖拽图片
Android通过手势(多点)缩放和拖拽图片
76 4
|
9月前
|
Java Android开发
android 下载图片的问题
android 下载图片的问题
72 3
|
6月前
|
数据处理 开发工具 数据安全/隐私保护
Android平台RTMP推送|轻量级RTSP服务|GB28181接入之文字、png图片水印的精进之路
本文探讨了Android平台上推流模块中添加文字与PNG水印的技术演进。自2015年起,为了满足应急指挥及安防领域的需求,逐步发展出三代水印技术:第一代为静态文字与图像水印;第二代实现了动态更新水印内容的能力,例如实时位置与时间信息;至第三代,则优化了数据传输效率,直接使用Bitmap对象传递水印数据至JNI层,减少了内存拷贝次数。这些迭代不仅提升了用户体验和技术效率,也体现了开发者追求极致与不断创新的精神。
|
6月前
|
自然语言处理 定位技术 API
Android经典实战之如何获取图片的经纬度以及如何根据经纬度获取对应的地点名称
本文介绍如何在Android中从图片提取地理位置信息并转换为地址。首先利用`ExifInterface`获取图片内的经纬度,然后通过`Geocoder`将经纬度转为地址。注意操作需在子线程进行且考虑多语言支持。
353 4
|
6月前
|
XML 前端开发 Android开发
Android经典实战之Kotlin中实现圆角图片和圆形图片
本文介绍两种实现圆角图像视图的方法。第一种是通过自定义Kotlin `AppCompatImageView`,重写`onDraw`方法使用`Canvas`和`Path`进行圆角剪裁。第二种利用Android Material库中的`ShapeableImageView`,简单配置即可实现圆角效果。两种方法均易于实现且提供动态调整圆角半径的功能。
127 0
|
8月前
|
Java Android开发
18. 【Android教程】图片控件 ImageView
18. 【Android教程】图片控件 ImageView
139 4
|
8月前
|
JSON 编解码 Apache
Android中使用HttpURLConnection实现GET POST JSON数据与下载图片
Android中使用HttpURLConnection实现GET POST JSON数据与下载图片
92 1
|
8月前
|
开发工具 Android开发
Android 代码自定义drawble文件实现View圆角背景
Android 代码自定义drawble文件实现View圆角背景
210 0
|
9月前
|
Android开发
Android中Glide加载Https图片失败的解决方案
Android中Glide加载Https图片失败的解决方案
566 1

热门文章

最新文章

  • 1
    【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
  • 2
    Android历史版本与APK文件结构
  • 3
    【01】噩梦终结flutter配安卓android鸿蒙harmonyOS 以及next调试环境配鸿蒙和ios真机调试环境-flutter项目安卓环境配置-gradle-agp-ndkVersion模拟器运行真机测试环境-本地环境搭建-如何快速搭建android本地运行环境-优雅草卓伊凡-很多人在这步就被难倒了
  • 4
    当flutter react native 等混开框架-并且用vscode-idea等编译器无法打包apk,打包安卓不成功怎么办-直接用android studio如何打包安卓apk -重要-优雅草卓伊凡
  • 5
    APP-国内主流安卓商店-应用市场-鸿蒙商店上架之必备前提·全国公安安全信息评估报告如何申请-需要安全评估报告的资料是哪些-优雅草卓伊凡全程操作
  • 6
    【03】仿站技术之python技术,看完学会再也不用去购买收费工具了-修改整体页面做好安卓下载发给客户-并且开始提交网站公安备案-作为APP下载落地页文娱产品一定要备案-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
  • 7
    【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
  • 8
    【02】仿站技术之python技术,看完学会再也不用去购买收费工具了-本次找了小影-感觉页面很好看-本次是爬取vue需要用到Puppeteer库用node.js扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
  • 9
    Cellebrite UFED 4PC 7.71 (Windows) - Android 和 iOS 移动设备取证软件
  • 10
    【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡