设置全屏:
必须在setContentView()之前调用
否则会报错:android.util.AndroidRuntimeException: requestFeature() must be called before adding content
// Full screen
// 隐藏Title(其中是项目名称)
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 隐藏系统的工具栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
设置软键盘不弹出:
// 关掉软键盘
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
几种表示大小的单位:
px(pixels) 像素 : 与设备相关。
dip/dp(device independent pixels) 设备独立像素 : 不依赖于设备,支持 WVGA 、 HVGA 等。布局时尽量使用单位 dip ,少使用 px 。
sp(scaled pixels) 放大像素 : 一般用于字体。
padding vs margin
padding 是该元素的主要内容到边框的距离 , 即内边距; 一般描述控件内容和控件的位置关系。
margin 是边框距离其他元素的距离,即外边距; 一般用来描述控件间 位置关系