Android 应用界面开发笔记 自定义控件与Handler -待更新
2016-03-20 22:58
471 查看
27th March 老师答疑更新
-关于第三周的作业
-Handler获取时间有可能会不准确,如果不停发送消息,刷新比较频繁,可能会造成堵塞,以至于时间控制不准确
Timer会更准确一些
-不建议调用系统的图片等资源,不同版本可能位值等不一样,可能会调用不到为空
- px, dp, sp, dip
画分割线可以用1px
dp = dip
LayoutInflater 将xml解析为视图
Activity继承于Context
获取布局的方式/获得LayoutInflater实例的三种方式 (xml -> view)
LayoutInflater layoutInflater = getLayoutInflater();
getSystemService (LAYOUT_INFLATER_SERVICE); // same as this method
LayoutInflater.from(context);
View view = mLayoutInflater.inlfate(R.layout.activity_main, null) //(int resource, ViewGroup root )
addContentView(view) // 可以将视图放在很多地方
view.findViewById(R.id. 找到视图里面的任何一个控件)
--16min
提取布局属性 theme & style
Theme 针对窗体级别,改变窗体样式 (for application, activity etc.
Style
//ctrl + o: enter class name
//ctrl + shift + o: enter file name
Style 可以继承,也可以override
-- Course 2
build a new view
new a view class, exteneds view, new a constructor
View
- initialize a constructor
-onMeasure(); decides the size
-onLayout(); the location
-onDraw();
-invalidate(); to refresh
fast-key: ctrl+F12, search method in current class
3 ways to customize widget
1, extend an existing widget
2, extends from a layout file
3, extends from a view class
shift + F6: reconstruct
做一个简单的自定义控件:15min
自定义视图的属性
-where
-what
-how to use those attributes
build a new .xml file under "values", <declare-styleable
xmlns: app="http://schemas.android.com/apk/res-auto"
自定义一个命名空间
Fragment
- fragment is a part of activity
- Create Fragment
. onCreate();
. onCreateView();
. onPause();
- Add Fragment
. Java Code
. Layout
- Replace Fragment
fragments can be used in one activity, or more
fragment has its own life period, is a modular activity, has its own behaviors, can be added, removed, deleted
-关于第三周的作业
-Handler获取时间有可能会不准确,如果不停发送消息,刷新比较频繁,可能会造成堵塞,以至于时间控制不准确
Timer会更准确一些
-不建议调用系统的图片等资源,不同版本可能位值等不一样,可能会调用不到为空
- px, dp, sp, dip
画分割线可以用1px
dp = dip
LayoutInflater 将xml解析为视图
Activity继承于Context
获取布局的方式/获得LayoutInflater实例的三种方式 (xml -> view)
LayoutInflater layoutInflater = getLayoutInflater();
getSystemService (LAYOUT_INFLATER_SERVICE); // same as this method
LayoutInflater.from(context);
View view = mLayoutInflater.inlfate(R.layout.activity_main, null) //(int resource, ViewGroup root )
addContentView(view) // 可以将视图放在很多地方
view.findViewById(R.id. 找到视图里面的任何一个控件)
--16min
提取布局属性 theme & style
Theme 针对窗体级别,改变窗体样式 (for application, activity etc.
Style
//ctrl + o: enter class name
//ctrl + shift + o: enter file name
Style 可以继承,也可以override
-- Course 2
build a new view
new a view class, exteneds view, new a constructor
View
- initialize a constructor
-onMeasure(); decides the size
-onLayout(); the location
-onDraw();
-invalidate(); to refresh
fast-key: ctrl+F12, search method in current class
3 ways to customize widget
1, extend an existing widget
2, extends from a layout file
3, extends from a view class
shift + F6: reconstruct
做一个简单的自定义控件:15min
自定义视图的属性
-where
-what
-how to use those attributes
build a new .xml file under "values", <declare-styleable
xmlns: app="http://schemas.android.com/apk/res-auto"
自定义一个命名空间
Fragment
- fragment is a part of activity
- Create Fragment
. onCreate();
. onCreateView();
. onPause();
- Add Fragment
. Java Code
. Layout
- Replace Fragment
fragments can be used in one activity, or more
fragment has its own life period, is a modular activity, has its own behaviors, can be added, removed, deleted
相关文章推荐
- Android5.x 新控件之RecyclerView使用总结
- 一个强大的Android模拟器Genymotion
- android捕获ListView中每个item点击事件
- android 中theme.xml与style.xml的区别
- Android-使用Intent传递对象
- Android Fragment学习小结
- Android开发中如何调用摄像…
- android: targetSdkVersion属性说明及其对应不同值会引起的问题
- Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/Accessibil
- Android进阶之AlertDialog自定义
- android(eclipse)编程中常见的java问题总结(四)
- Android——简易音乐播放器
- Android 设置主题实现点击波纹效果
- Android 内容提供器(Content Provider)
- progressblock 安卓自定义进度条 progressbar 高仿仿QQ下载进度条
- Android Service 与Activity之间的通讯方式
- Android 开发个人总结
- Android热补丁技术—dexposed原理简析(手机淘宝采用方案)
- 探究android控件及布局
- Android动画使用