摘要: 本文原创, 转载请注明出处:http://blog.csdn.net/qinjuning 在之前一篇博文... 阅读全文
posted @ 2016-10-02 11:34 杨伟乔 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 本文原创, 转载请注明出处:http://blog.csdn.net/qinjuning 上篇文章>中,我们 了解了View树的转换过程以及如何设置View的LayoutParams的。本文继续沿着既定轨迹继... 阅读全文
posted @ 2016-10-02 11:34 杨伟乔 阅读(303) 评论(0) 推荐(0) 编辑
摘要: View 就是屏幕上的一块矩形区域. Android原生桌面上的那些应用图标其实是 textview, 可以再 Android Device Monitor 中看(dump view). View只能有一个父View, 为什么? 这样设计, 系统底层只需跟最顶层的View交互. View是否必须有父View, 不是, 可以使用 WindowManager 加到屏幕上Android是 C/S 架... 阅读全文
posted @ 2016-10-02 11:33 杨伟乔 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 在上一篇里, 自定义View的背景色和文字颜色都是在 onDraw 里写死的, 这次我们实现可以通过布局文件配置. 要实现这个功能, 需要有如下几个步骤:1. 创建 attrs.xml在 res/values 目录下新建一个 attrs.xml , 内容如下: 2. 在布局文件中使用 注意:1. 要在最外层... 阅读全文
posted @ 2016-10-02 11:19 杨伟乔 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 自定义一个View, 继承自 View, 实现如下效果: 其实就是一个宽高为100的蓝色方块, 左下角红色字题 Hello! (上面的Hello world 是系统的 TextView).1. 继承 View, 重写 onDraw 方法/** * 自定义一个简单的 View * * @author GAOYUAN * */public class CustomView1 extends Vie... 阅读全文
posted @ 2016-10-02 11:18 杨伟乔 阅读(242) 评论(0) 推荐(0) 编辑
摘要: Android offers a sophisticated and powerful componentized model for building your UI, based on the fundamental layout classes: View and ViewGroup. To start with, the platform includes a variety of ... 阅读全文
posted @ 2016-10-02 11:15 杨伟乔 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 转自http://www.cnblogs.com/hdjjun/archive/2011/10/12/2209467.html 代码为自己编写目标:实现textview和ImageButton组合,可以通过Xml设置自定义控件的属性。 通过代码或者通过xml设置自定义控件的属性1.控件布局:以Linearlayout为根布局,一个TextView,一个ImageButton。 Xm... 阅读全文
posted @ 2016-10-02 11:14 杨伟乔 阅读(498) 评论(0) 推荐(0) 编辑