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

杭州外贸网站建设昆明做网站设计

杭州外贸网站建设,昆明做网站设计,cms网站开发模式,牛商网营销型网站建设主要实现的那种光晕效果&#xff1a;中间亮&#xff0c;四周逐渐变淡的。 这边有三种发光效果&#xff0c;先上效果图。 第一种、圆形发光体 实现代码&#xff1a;新建shape_light.xml&#xff0c;导入以下代码。使用时&#xff0c;直接给view设置为background。 <?xml …

主要实现的那种光晕效果:中间亮,四周逐渐变淡的。

这边有三种发光效果,先上效果图。

第一种、圆形发光体

实现代码:新建shape_light.xml,导入以下代码。使用时,直接给view设置为background。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval"><gradientandroid:centerColor="@color/transparent"android:centerX="0.5"android:centerY="0.5"android:gradientRadius="180dp"android:startColor="@color/yellow"android:type="radial" />
</shape>

第二种、矩形发光体

代码实现:通过自定义view实现。

package com.fht.testprojectimport android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import android.view.View/*** @author fenghaitao* @time 2023/11/1 16:40*/
class RectLightView @JvmOverloads constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int = 0
) : View(context, attributeSet, defStyleAttr) {private val paint: Paint = Paint()private val corner = 50fprivate val count = 200init {paint.isAntiAlias = falsepaint.style = Paint.Style.FILLpaint.color = Color.YELLOW}@SuppressLint("DrawAllocation")override fun onDraw(canvas: Canvas?) {super.onDraw(canvas)val w = width / countval h = height / countfor (i in 0..count) {paint.alpha = (255 / count) * iif (((width - 2 * (w * i)) > 0) && ((height - 2 * (h * i)) > 0)) {val rectF = RectF().apply {left = (w * i).toFloat()top = (h * i).toFloat()right = (width - w * i).toFloat()bottom = (height - h * i).toFloat()}canvas?.drawRoundRect(rectF, corner, corner, paint)}}}
}

第三种、矩形发光体,比上一种更透明

这种有点瑕疵,中间有一点空白,不过稍微修改一下代码也可以去掉,这里就不做修改了。

代码实现:通过自定义view实现。

package com.fht.testprojectimport android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import android.view.View/*** @author fenghaitao* @time 2023/11/1 16:40*/
class LightView @JvmOverloads constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int = 0
) : View(context, attributeSet, defStyleAttr) {private val paint: Paint = Paint()private val corner = 1fprivate val count = 100init {paint.isAntiAlias = falsepaint.style = Paint.Style.STROKEpaint.color = Color.YELLOW}@SuppressLint("DrawAllocation")override fun onDraw(canvas: Canvas?) {super.onDraw(canvas)val w = width / countval h = height / countpaint.strokeWidth = w.toFloat()for (i in 0..count) {paint.alpha = (255 / count) * iif (((width - 2 * (w * i)) > 0) && ((height - 2 * (w * i)) > 0)) {val rectF = RectF().apply {left = (w * i).toFloat()top = (w * i).toFloat()right = (width - w * i).toFloat()bottom = (height - w * i).toFloat()}canvas?.drawRect(rectF, paint)}}}
}

http://www.yayakq.cn/news/330458/

相关文章:

  • 盐城企业网站制作seo优化方案书
  • 品牌型网站建设vi设计 站酷
  • 深圳网站优化技巧如何查看小程序的开发公司
  • 佛山seo联系方式信息流优化师发展前景
  • asp 课程教学网站开发ftp查看网站后台密码
  • 银川网站制作报价wordpress试用
  • 长沙房地产公司排名培训seo技术
  • 国外高端网站视频格式转换网页版
  • 网站建设实训周记东莞建筑企业招聘
  • 江苏省建设厅网站施工员证查询南昌有做网站的吗
  • 用hexo做网站贵州省住房和城乡建设厅门户网站
  • 重庆做网站找谁php调用网站导航怎么弄
  • 网站价格评估 优帮云厂房建设招标网站
  • 网站怎么做cdn定制做网站
  • 官方网站建设报价网络营销方式英语
  • 自适应企业网站源码商城形式的网站需要多少钱
  • 天津企业网站建站教程的实现方式
  • 手机版文章网站源码什么网站做ppt好
  • ps做简洁大气网站北京市建设工程造价管理处网站
  • 徐州徐州网站建设鹤峰网站建设
  • 厅门户网站建设苏州网址
  • 国外网站 备案吗网页设计工作室选址依据
  • 宝安做网站公司乐云seo郑州网站建设学习
  • 网站建站的尺寸微网站和手机网站
  • 苏州网站建设网站制作的公司扬州大学第四届网站建设评比
  • 《网站建设与管理》论文wordpress自动评论工具
  • 做网站应怎么缴税湖南企业app下载
  • 外贸网站如何优化wordpress微信验证码
  • 广告网站模板网站建设 中企动力宜昌
  • 网站建设客户需求wordpress 产品筛选