Google发布,玩转ShapeableImageView,告别第三方库,2024年最新一文搞懂Golang架构

####各种花俏样式 1、圆角图片

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image1”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/roundedCornerStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

2、圆形图片

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image2”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/circleStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

3、切角图片

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image3”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/cutCornerStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

4、菱形图片

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image4”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/diamondStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

5、右上角圆角图片

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image5”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/topRightCornerStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

6、小鸡蛋图片

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image6”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/eggStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

7、组合弧度图片效果

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image7”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/comCornerStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

8、 小 Tips

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image8”
android:layout_width=“110dp”
android:layout_height=“50dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/tipsCornerStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

9、扇形图片

<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/image9”
android:layout_width=“110dp”
android:layout_height=“110dp”
android:padding=“1dp”
android:src=“@drawable/head”
app:shapeAppearance=“@style/fanStyle”
app:strokeColor=“@android:color/holo_blue_bright”
app:strokeWidth=“2dp”/>

对应的style:

通过源码学知识

从前面应用可以发现,通过定义ShapeableImageView的shapeAppearance属性style值,可以实现各种不同的样式,而style有哪些的属性,分别表示什么,定义了这些style实现这些样式效果的原理是什么,带着这些疑问阅读源码。

public ShapeableImageView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(wrap(context, attrs, defStyle, DEF_STYLE_RES), attrs, defStyle);
// Ensure we are using the correctly themed context rather than the context that was passed in.
context = getContext();

clearPaint = new Paint();
clearPaint.setAntiAlias(true);
clearPaint.setColor(Color.WHITE);
clearPaint.setXfermode(new PorterDuffXfermode(Mode.DST_OUT));
destination = new RectF();
maskRect = new RectF();
maskPath = new Path();
TypedArray attributes =
context.obtainStyledAttributes(
attrs, R.styleable.ShapeableImageView, defStyle, DEF_STYLE_RES);

strokeColor =
MaterialResources.getColorStateList(
context, attributes, R.styleable.ShapeableImageView_strokeColor);

strokeWidth = attributes.getDimensionPixelSize(R.styleable.ShapeableImageView_strokeWidth, 0);

borderPaint = new Paint();
borderPaint.setStyle(Style.STROKE);
borderPaint.setAntiAlias(true);
shapeAppearanceModel =
ShapeAppearanceModel.builder(context, attrs, defStyle, DEF_STYLE_RES).build();
shadowDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
setOutlineProvider(new OutlineProvider());
}
}

在构造方法中有两行核心代码:

shapeAppearanceModel =
ShapeAppearanceModel.builder(context, attrs, defStyle, DEF_STYLE_RES).build();
shadowDrawable = new MaterialShapeDrawable(shapeAppearanceModel);

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Go语言工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Go语言全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Golang知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注Go)
img

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

涵盖了95%以上Golang知识点,真正体系化!**

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注Go)
[外链图片转存中…(img-O3AnWkW4-1712968539695)]

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 30
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值