文章分类 - android自定义控件
摘要:第一类:属性值 true或者 false Android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android:layout_centerInparent 相对于父元素完全居中 android:layout_al
阅读全文
摘要:转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 简介: 在自定义view的时候,其实很简单,只需要知道3步骤: 1.测量——onMeasure():决定View的大小 2.布局——onLayout():决定View在ViewGroup中的
阅读全文
摘要:简介: 在自定义view的时候,其实很简单,只需要知道3步骤: 1.测量——onMeasure():决定View的大小 2.布局——onLayout():决定View在ViewGroup中的位置 3.绘制——onDraw():如何绘制这个View。 而第3步的onDraw系统已经封装的很好了,基本不
阅读全文
摘要:控件有很多属性,如android:id、android:layout_width、android:layout_height等,但是这些属性都是系统自带的属性。使用attrs.xml文件,可以自己定义属性。本文在Android自定义控件的基础上,用attrs.xml文件自己定义了属性。 首先,在va
阅读全文
摘要:1.在res/values下创建attrs.xml <declare-styleable name="MyRadioButton"> <attr name="str" format="string"/> </declare-styleable> MyRadioButton为组件名字,随意起,attr
阅读全文
摘要:Android中在values中定义一个attrs.xml,然后自己定义一个组件MyView attrs.xml内容如下: [html] view plain copy <?xml version="1.0" encoding="utf-8"?> <resources> <declare-style
阅读全文
摘要:开发自定义控件的步骤: 1、了解View的工作原理 2、 编写继承自View的子类 3、 为自定义View类增加属性 4、 绘制控件 5、 响应用户消息 6 、自定义回调函数 一、View结构原理 Android系统的视图结构的设计也采用了组合模式,即View作为所有图形的基类,Viewgroup对
阅读全文