当前位置: 首页 > news >正文

注册网站会员需填写wordpress瀑布墙

注册网站会员需填写,wordpress瀑布墙,聊城市 网站制作,做加盟的网站文章目录 1.通过给view设置background实现圆角2.通过glide加载图片设置圆角3.通过CardView实现圆角4.利用View 的 ViewOutlineProvider 实现圆角 1.通过给view设置background实现圆角 这种方式是通过shape设置背景色的方式实现圆角#xff0c;不影响view的绘制区域#xff0… 文章目录 1.通过给view设置background实现圆角2.通过glide加载图片设置圆角3.通过CardView实现圆角4.利用View 的 ViewOutlineProvider 实现圆角 1.通过给view设置background实现圆角 这种方式是通过shape设置背景色的方式实现圆角不影响view的绘制区域只是通过设置背景色影响显示区域来实现圆角 ?xml version1.0 encodingutf-8? shape xmlns:androidhttp://schemas.android.com/apk/res/androidcornersandroid:bottomLeftRadius11dp/solid android:colorcolor/element_tcl_navigation_item_bg_middle_focus_color / /shapecorner标签代表圆角支持设置4个圆角一个单个圆角设置 bottomLeftRadius 左下圆角 bottomRightRadius : 右下圆角 topLeftRadius : 左上圆角 topRightRadius :右上圆角 solid标签代表填充色纯色填充 gradient标签代表渐变色填充 shape也支持java代码创建 GradientDrawable在Android 中便是shape标签的代码实现 val gradientDrawable background as GradientDrawable gradientDrawable.setColor(Color.GRAY) gradientDrawable.cornerRadius 10F view.background gradientDrawable上述就是代码动态创建shape的示例 想要设置某个圆角可以使用 val radii floatArrayOf(corner,corner,0f,0f,0f,0f,corner,corner) gradientDrawable.cornerRadii radiisetCornerRadii(Nullable float[] radii) 该方法实现某个圆角的设置对应关系就是8位数组是左上右上右下左下两位对应一个圆角值就是想要的圆角值。 ?xml version1.0 encodingutf-8? layer-list xmlns:androidhttp://schemas.android.com/apk/res/androiditemandroid:left5dpandroid:right5dpshapesolid android:colorcolor/white /cornersandroid:bottomLeftRadius10dpandroid:topLeftRadius10dp //shape/item/layer-list需要注意这种layer-list的写法这种需要代码动态创建时需要用到LayerDrawable 这种方式需要动态修改shape的时候需要 val layerDrawable background as LayerDrawableval drawable layerDrawable.getDrawable(0)val drawables arrayOf(drawable)val realLayoutDrawable LayerDrawable(drawables)//layer drawable left 和 right的值realLayoutDrawable.setLayerInset(0, 5,0,5,0 )view.background realLayoutDrawablelayerDrawable相当于一个数组中包含了很多GradientDrawable需要修改时需要先get出来 修改后再放入即setLayerInset(int index, int l, int t, int r, int b) 2.通过glide加载图片设置圆角 fun loadImageIntoBackgroundWithSomeCorner(view: View,context: Context,url: String,topLeftCorner: Int,topRightCorner: Int,bottomLeftCorner: Int,bottomRightCorner: Int,imageLoaderDrawableListener: ImageLoaderDrawableListener) {val roundedCorners GranularRoundedCorners(topLeftCorner.toFloat(),topRightCorner.toFloat(),bottomRightCorner.toFloat(),bottomLeftCorner.toFloat())val requestOptions RequestOptions().transform(CenterCrop(), roundedCorners)Glide.with(context).asBitmap().load(url).apply(requestOptions).into(object : CustomViewTargetView, Bitmap(view) {override fun onLoadFailed(errorDrawable: Drawable?) {imageLoaderDrawableListener.onLoadFail()}override fun onResourceReady(resource: Bitmap, transition: Transitionin Bitmap?) {if (resource ! null !resource.isRecycled) {imageLoaderDrawableListener.onLoadImageSuccess(url, BitmapDrawable(context.resources, resource))}}override fun onResourceCleared(placeholder: Drawable?) {}})}Glide加载图片圆角通过设置RequestOptions来实现 GranularRoundedCorners(float topLeft, float topRight, float bottomRight, float bottomLeft) {this.topLeft topLeft;this.topRight topRight;this.bottomRight bottomRight;this.bottomLeft bottomLeft; }GranularRoundedCorners可以设置单个圆角 RoundedCorners(int roundingRadius)RoundedCorners是直接设置4个圆角 3.通过CardView实现圆角 CardView 是自带圆角实现的我们只需要在它的定义中加一句 app:cardCornerRadius”10dp” 即可。 ?xml version1.0 encodingutf-8? androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent androidx.cardview.widget.CardViewandroid:layout_width256dpandroid:layout_height128dpapp:cardBackgroundColor#0084FFapp:cardCornerRadius10dpapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparent / /androidx.constraintlayout.widget.ConstraintLayout CardView是原生组件缺点是只支持四个圆角设置 4.利用View 的 ViewOutlineProvider 实现圆角 ViewOutlineProvider 是Android 5.0之后新增的设置圆角的方式。 RequiresApi(Build.VERSION_CODES.LOLLIPOP) class VideoListOutlineProvider(private val radius: Int, private val ancorView: View?) :ViewOutlineProvider() {companion object {const val radiusLeft 1const val radiusRight 2}//圆角左边或者右边private var radiusDirection radiusLeftconstructor(radiusDirection: Int, radius: Int, ancorView: View?) : this(radius, ancorView) {this.radiusDirection radiusDirection}override fun getOutline(view: View, outline: Outline?) {if (radiusDirection radiusLeft) {outline?.setRoundRect(0, 0, view.width radius, view.height, radius.toFloat())} else if (radiusDirection radiusRight) {outline?.setRoundRect(-radius, 0, view.width, view.height, radius.toFloat())}} }这种实现方式本质上是修改了 View 的轮廓。 本质来说此种方式只支持设置4个圆角但是可以控制裁剪区域实现单个圆角的绘制需要注意识别清楚裁剪区域不然会导致view直接被裁剪丢弃。具体参照上述实现。
http://www.zqtcl.cn/news/293869/

相关文章:

  • 商城类网站用什么做珠海找工作哪个网站好
  • 宁波建站模板厂家太原企业网站排名
  • 厦门网站建设定制多少钱wordpress能用一个数据库
  • 找人做网站需要准备什么材料怎么建设自己淘宝网站首页
  • 汽车网站建设费用js怎么做网站
  • 四川万景建设工程有限公司网站做公司网站用什么系统
  • 长沙企业建站系统3d视频制作公司
  • 长沙的网站制作公司网站建设方案的需求分析
  • 电子商务网站发展建设论文网站开发需要经过的几个主要阶段
  • 建设网站外贸做网站必须会php吗
  • 网站建设费用的请示丹徒区建设局网站
  • 上海网站制作机构个人做外贸网站违法吗
  • 咖啡厅网站开发目标汕头最新消息今天
  • 广州做外贸网站的公司简介做行业门户网站注意什么
  • 专业网页网站设计图书成都医院做网站建设
  • 浙江网站建设dyfwzx网站开发的广告词
  • 网站 seo 优化 效果中华室内设计网公众号下载
  • 如何自己建网站企业网站建站快车的优点
  • 目前做网站的公司有哪些管理系统中的计算机应用
  • 百度网站服务器企业网站报价
  • 网站后台账户如何做会计分录电商数据查询平台
  • 素材动图网站90设计app下载
  • 绍兴网站设计公司网站空间位置是什么
  • 高端网站设计品牌珠海网站建设最新报价
  • 做网站的商家怎么赚取流量费房地产怎么做网站推广
  • 企业网站建设基本流程网站积分方案
  • 网站定位与功能分析网站常见故障
  • 深圳电子商务网站制作桂林市防疫最新政策
  • 北京网站建设备案代理网站建设计划建议
  • 湛江公司做网站wordpress如何设置网站地图