当前位置: 首页 > 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://www.yutouwan.com/news/461557/

相关文章:

  • 江苏省内网站建设移动商城个人中心
  • 网站做标签搭建一个网站多少钱
  • 网站源码做exe执行程序网络营销如何进行网站推广
  • 长沙做网站推广公司咨询犀牛云网站做的怎么样
  • 手机网站开发标准即时设计网页
  • 如何创建一个网站用来存放东西合肥网站推广 公司
  • 免费的开发网站建设哪里 教做网站带维护
  • 公众号怎么做微网站html 购物网站
  • 怎么做查询网站网站前台和后台
  • WordPress站群模版开发一个小程序流程
  • 建设网站合同范本登不了wordpress
  • 外贸网站示例哪里有好网站设计
  • 河间哪里有做网站的上海网站建设导航
  • 网站搭建的意义个人网站备案没有座机
  • 资中移动网站建设平台引流推广怎么做
  • 建设信用卡在网站挂失几步58同城最新招聘网
  • 宝和网站建设如何建设酒店预订系统网站
  • 会计题库网站怎么做win7如何安装iis来浏览asp网站
  • 免费自己制作app软件下载安徽优化网站
  • 济南住房与城乡建设官网网站标题具体怎样优化
  • 学校网站下载租用云服务器多少钱
  • 慈溪市网站开发如何选择宜昌网站建设
  • 做视频网站需要什么服务器配置建设网站初步目标咋写
  • 家居网站建设营销推广来个网站2021能用的
  • 名气特别高的手表网站东源建设局网站
  • 建设局特种作业网站湖北省建设厅网站首页
  • 东莞网站建设品牌网站开发兼容问题
  • 一级造价工程师报名网站数码产品商务网站建设
  • 商务网站建设考试题库前端网页设计师
  • wordpress安装失败asp网站 seo