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

南宁网站优化推广方案宣传片制作公司前景

南宁网站优化推广方案,宣传片制作公司前景,龙岩网站定制,医美类网站如何做推广一、概念 在 xml 中为控件设置的属性。自定义属性名称如果使用系统已定义的#xff0c;例如 textSize 会在编译时报错。 格式类型定义/使用 string 字符串 attr name myContent format color / android:myContent Hello Word!例如 textSize 会在编译时报错。 格式类型定义/使用 string 字符串 attr name myContent format color / android:myContent Hello Word! color 颜色 attr name myTextColor format color / android:myTextColor #00FF00 dimension 尺寸 attr name myTextSize format dimension / android:myTextSize 12.sp reference 资源 attr name myBackground format reference / android:myBackground drawable/图片ID boolean 布尔 attr name myEnable format boolean / android:myEnable true float 浮点 attr name myAlpha format float / android:myAlpha 0.5F integer 整型 attr name myMaxLines format integer / android:myMaxLines 3 fraction 百分比 attr name myOffset format fraction / android:myOffset 10% enum 枚举 attr name myOrientation         enum name horizontal value0 /         enum name vertical value1 / /attr android:myOrientation vertical flag 位运算 位运算类型的属性在使用的过程中可以使用多个值 attr name myGravity /         flag nematop value0x01         flag nemaleft value0x02         flag nemacenter_vertical value0x02 /attr android:myGravity top|left 混合类型 属性定义时可以指定多种类型值 attr name myBackground format reference|color / android:myBackground drawable/图片ID android:myBackground #00FF00 二、自定义步骤 2.1 创建资源文件属性声明 右键 values 目录 - New File文件 - 一般取名attrs.xml。 resources!--name使用自定义View的名称--declare-styleable nameMyView!--name属性名称format格式--attr namemyText formatstring /attr namemyTextColor formatcolor /attr namemyTextSize formatdimension /attr namemyMaxLength formatinteger /attr namemyBackground formatreference|color /!--枚举--attr namemyInputTypeenum namenumber value1/enum nametext value2//attr/declare-styleable /resources 2.2 构造函数中配置 constructor(context: Context?) : super(context) 重写一个参数的构造函数使用场景代码 new 创建实例的时候调用。 constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) 重写两个参数的构造函数使用场景xml中使用时调用xml转java代码的时候反射。 constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) 重写三个参数的构造函数使用场景使用主题Style的时候调用。 class MyView : View {private var text: String? nullprivate var textSize: Int? nullprivate var textColor: Int? nullprivate var maxLength: Int? nullprivate var background: Int? nullprivate var inputType: Int? null//改成this调用2个参数的构造constructor(context: Context?) : this(context, null)//改成this调用3个参数的构造constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)//在这里统一进行处理constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {context?.let {//返回一个与attrs中列举出的属性相关的数组数组里面的值由样式属性指定val attributes it.obtainStyledAttributes(attrs, R.styleable.MyView)//获取自定义属性(格式属性名称_条目名称)text attributes.getString(R.styleable.MyView_myText)textSize attributes.getDimensionPixelSize(R.styleable.MyView_myTextSize, 0)textColor attributes.getColor(R.styleable.MyView_myTextColor, Color.BLACK)maxLength attributes.getInt(R.styleable.MyView_myMaxLength,1)background attributes.getResourceId(R.styleable.MyView_myBackground,R.drawable.ic_launcher_foreground)inputType attributes.getInt(R.styleable.MyView_myInputType,0)//回收资源attributes.recycle()}} } 2.3 布局中使用属性使用 根布局添加命名空间只需要输入appIDE会自动补全。控件名称使用完整路径只需要输入自定义View的类名IDE会自动补全。未自定义的属性View会去处理继承自View使用自定义的属性就是 app: 开头的。 !--根布局添加命名空间-- LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationvertical!--控件名称使用完整路径--com.example.kotlindemo.view.MyViewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentapp:myBackgrounddrawable/ic_launcher_foregroundapp:myInputTypenumberapp:myTextHello Word!app:myTextColorcolor/blackapp:myTextSize20spapp:myMaxLength20/ /LinearLayout
http://www.sczhlp.com/news/223944/

相关文章:

  • 江门微信网站建设开发一个游戏需要多少钱
  • 网站建设费是什么意思高埗镇仿做网站
  • 淘宝官方网站登录注册免费公司logo设计大全
  • 网站备案证图片二级域名怎么做网站
  • 随州网站推广哪家权威20个外国平面设计网站
  • 做网站用什么源码好乡村振兴网站建设
  • 建设一个网站多少钱宁德网页设计制作
  • 必应网站管理员工具wordpress朋友圈
  • 网页设计公司未来三年规划贵阳seo排名
  • 如何引用网站上的资料做文献重庆在线平台
  • 在线生成个人网站vs音乐网站开发实例
  • 南平摩托车罚款建设网站缴费做网站怎么防止被黑
  • 广州微信网站网站域名和空间
  • 南江县建设局网站个人业务网站源码php
  • c 网站建设可视化实现后台管理系统页面模板
  • 北京住房建设部网站文本怎样做阅读链接网站
  • 深圳定制网站制作厂家兰州网站建设推荐q479185700上墙
  • 网站建设与制作dw8教程网站添加二维码
  • 搞定三大PLC通讯:倍福与西门子、欧姆龙与西门子数据互通实战
  • AI元人文构想与余溪诗学空间:一场从诗意本源向智能未来的远征
  • 临沂高端网站建设网站建设需求怎么提
  • 蚌埠市重点工程建设管理局网站自建站公司
  • 电话销售做网站打官司免费一键生成app工具
  • 整屏网站模板轻松建立网站
  • 丹棱网站建设山东东营市天气预报
  • 宜昌网站建设重庆如何做聚政网站
  • 专做立体化的网站网站上的图标用什么软件做的
  • 网站开发可能存在的困难设计网站的在工作中的品牌网站
  • 上线了小程序北京专业seo
  • 广州网站制作开发网站的登录界面是怎么做的