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

上海如何优化网站湖州网站设计平台

上海如何优化网站,湖州网站设计平台,火山软件开发平台官网,代理网址是什么Android 自定义组件 Android 提供了非常精致的和非常强大的组件化模型#xff0c;能够更加方便的构建UI,这些UI组件都是基于基本的layout类:View 和 ViewGroup。 部分能够用的widgets包括#xff1a;Button#xff0c;TextView,EditText,ListView,CheckBox#xff0c;Radio… Android 自定义组件 Android 提供了非常精致的和非常强大的组件化模型能够更加方便的构建UI,这些UI组件都是基于基本的layout类:View 和 ViewGroup。 部分能够用的widgets包括ButtonTextView,EditText,ListView,CheckBoxRadioButton,Gallery,Spinner,和一些比较特殊用途的widgetsAutoCompleteTextView, ImageSwitcher, and TextSwitcher. 布局组件有LinearLayout, FrameLayout, RelativeLayout,absoluteLayout,TabelLayout 如果预定义的widgets和布局组件都不符合您的需求那就需要创建属于自己的view如果只是需要对已有的widget和layout进行小部分的调整那就可以通过重写部分一些方法来完成开发。 下面就举个例子讲解如何创建自定义的xml属性以及如果使用。 1. 首先创建一个新的android application. 2. 创建属性在res/values/ 下创建一个attr.xml 文件定义好需要的attributes ?xml version1.0 encodingutf-8? resourcesdeclare-styleable namecustomattr nametext formatstring /attr namesize formatinteger/attr namecolor formatreference|color//declare-styleable /resources 3. 创建自定义的View 创建一个View CustomView 继承自View(根据具体的情况如果需求和已经存在的widget或者layout相差不大就继承重写一些方法) package com.hualu.androidview;import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; import android.view.View;public class CustomView extends View {private Paint p null;private String text null;public CustomView(Context context) {super(context);initCustomView() ;}public CustomView(Context context, AttributeSet attrs){super(context, attrs ) ;initCustomView() ;TypedArray a context.obtainStyledAttributes(attrs,R.styleable.custom) ;int indexCount a.getIndexCount() ;for(int i 0 ; i indexCount ; i ){int index a.getIndex(i) ;switch (index) {case R.styleable.custom_text:text a.getString(index) ;break;case R.styleable.custom_size:p.setTextSize(a.getInt(index, 0)); break;case R.styleable.custom_color:p.setColor(a.getColor(index, 0xFF000000)) ;break;}}a.recycle() ;}void initCustomView(){p new Paint();p.setAntiAlias(true);} ;Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);canvas.drawText(text, 10, 10, p) ;}}4. 在layout的文件使用自定义的view RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:customhttp://schemas.android.com/apk/res/com.hualu.androidviewxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context.MainActivity TextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_centerHorizontaltrueandroid:layout_centerVerticaltrueandroid:textstring/hello_world /com.hualu.androidview.CustomViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentcustom:textcustom viewcustom:color#00FF00custom:size18//RelativeLayout 5. 运行应用 结果 转载于:https://www.cnblogs.com/java20130722/archive/2013/03/31/3207276.html
http://wiki.neutronadmin.com/news/461557/

相关文章:

  • 免费搭建网站的软件贸易公司简介模板
  • 网页制作技术实训报告苏州百度推广排名优化
  • 河北建设信息平台网站泉州免费建站模板
  • 网站html有了怎么建设网站做牛仔的时尚网站
  • 苏州市市政建设集团公司网站刚刚发布了天津的最新消息
  • 全国最大的网站建设公司网站怎么放在服务器上
  • 网站项目验收国内免费接码
  • 抚宁区建设局网站口碑好的合肥网站建设
  • 解析网站dns宁波专业建网站外包
  • 网站的付款链接怎么做的网站建设与推广长春
  • 安康相亲平台医院网站优化
  • 福建建设注册中心网站企业培训方案制定
  • 建立网站的文案怎么写手机网站菜单代码
  • 免费做字体的网站养殖网站模板
  • 应式网站网站推广优化教程
  • 不上此网站枉做男人视频门户网站建设方案
  • 宝安大型商城网站建设小程序开发公司官网
  • app官方网站开源php企业网站
  • 品牌网站建设费用国内设计的企业网站
  • 如何用群晖做自己的网站查看网站域名
  • 伊川网站开发培训网站建设公司
  • 电子商务网站设计实验报告企业移动网站建设商
  • 我想建设网站visual studio网站开发
  • 那些网站是用python做的地方网站推广
  • 鹏达建设集团有限公司网站东莞网站公司排名
  • 找别人做的网站怎样修改企业管理系统oa
  • 网站后台模板论坛嘉行传媒
  • 绍兴建设局网站首页visual studio怎么做网页
  • 南昌网站搭建记账公司如何拉客户
  • 做内容的网站如何建设一个网站站