shehuan / niceimageview Goto Github PK
View Code? Open in Web Editor NEWAndroid 圆角、圆形 ImageView
License: Apache License 2.0
Android 圆角、圆形 ImageView
License: Apache License 2.0
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1) {
canvas.drawPath(path, paint);
} else {
srcPath.addRect(srcRectF, Path.Direction.CCW);
// 计算tempPath和path的差集
srcPath.op(path, Path.Op.DIFFERENCE);
canvas.drawPath(srcPath, paint);
srcPath.reset();//1
}
再onDraw方法中添加注释1处的代码就好了
rencycleview+item里设置了这个圆形图片,项目里的recyleview切换话anr特别卡顿
在每个item中设置了一个四个角圆角的图片,圆角时有时无的?
DrawerLayout中使用Glide、NiceImageView加载图片圆角失效:
侧划页使用GrawerLayout+LinearLayout,用户头像使用NiceImageView,使用Glide加载图片,GrawerLayout开启、关闭的时候,NiceImageView会不断进行“圆型”、“方形切换”。
<com.othershe.library.NiceImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="30dp"
android:src="@mipmap/tab_me"
android:background="@color/colorPrimary"
app:is_circle="true"
/>
会不断的抖动
最好不要在项目中直接写死com.android.support:appcompat-v7的版本,如果导入时版本不兼容,gradle会报错.
在readme中说明需要导入com.android.support:appcompat-v7:+即可.
或者实在不想改的话,这么导也是可以的
implementation('com.github.SheHuan:NiceImageView:1.0.5') {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
怎么设置宽度固定,高度自适应
NiceImageView 设置成圆形图片
如果把scaleType设置成centerCrop 设置的图片的宽高比不等于控件的宽高比并且设置有边框,会漏出来两条线
NiceImageView niceImageView = new NiceImageView(this);
niceImageView.setLayoutParams(new LinearLayoutCompat.LayoutParams(300,300));
niceImageView.setBackgroundResource(R.drawable.cat);
viewGroup.addView(niceImageView);
niceImageView.setCornerRadius(12);
我在小米开发版10 8.9.20 出现 Detected problems with API compatibility (visit g.co/dev/appcompat for more info) 这个问题 头像出现方形 原本是圆形
组合图片实现不了圆图,不稳定
Youtube
app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
A activity裡面有圓角圖片,跳轉到B activity,從B返回A後,A頁面的圓角圖片就失效了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.