您的位置:首页 > 移动开发

Android学习笔记-Lesson 5: Flag Quiz Game App (1)

2014-09-01 00:00 239 查看
Lesson 5知识点摘要:

1 Fragments / FragmentManager

can be combined

Layouts for multiple devixe orientations

2 Options Menu - configure the app's preferences and ActionBar

3 PreferenceFragment - manage and persist user preferences

4 AssetManager and the res subfolder assets

5 Tweeened animation - shake a flag for incorrect response

6 Hadler - schedule a future task to perform on the GUI thread

7 Android's loggin mechanism for logging error messages

还是从布局开始:

1 在string中配置时,遇到一个字符串如下:

<string name="results">%1$d guesses, %2$.02f%% correct</string>

其中,%后的1$和2$分别代表第一个变量和第二个变量

2 Android中sp,dp,dip,pt和px的区别

dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA、HVGA和QVGA 推荐使用这个,不依赖像素。

dp: dip是一样的

px: pixels(像素). 不同设备显示效果相同,一般我们HVGA代表320x480像素,这个用的比较多。

pt: point,是一个标准的长度单位,1pt=1/72英寸,用于印刷业,非常简单易用;

sp: scaled pixels(放大像素). 主要用于字体显示best for textsize。

据px = dip * density / 160,则当屏幕密度为160时,px = dip

根据 google 的建议,TextView 的字号最好使用 sp 做单位,而且查看TextView的源码可知Android默认使用sp作为字号单位。将dip作为其他元素的单位

3 创建不同的设备的layout:

譬如,for平板横向的设计,可以在res下面新建文件夹:layout-large-land, 将相关的layout文件放入其中,layout是标准开头,large代表是大的设备,譬如tablet,land代表横向。关于文件夹命名规范参考:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: