随手笔记:
1 屏幕适配:UI和UE
- 有4种普遍尺寸:小(small),普通(normal),大(large),超大(xlarge)
eg ;MyProject/ res/ layout/ main.xml layout-large/ main.xml
layout文件的名字必须完全一样,为了对相应的屏幕尺寸提供最优的UI,文件的内容不同。
- 4种普遍分辨率:低精度(ldpi), 中精度(mdpi), 高精度(hdpi), 超高精度(xhdpi)
mdpi/hdpi/xhdpi/xxhdpi 比例 1 : 1.5 :2 : 3
2 系统适配
Android在Build常量类中提供了对每一个版本的唯一代号,在我们的app中使用这些代号可以建立条件,保证依赖于高级别的API的代码,只会在这些API在当前系统中可用时,才会执行。
private void setUpActionBar() {
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
}
}