Android 開發雜記(不斷更新中)

2021-07-16 17:58:41 字數 984 閱讀 2659

方法一:

windowmanager wm = (windowmanager) this

.getsystemservice(context.window_service);

int width = wm.getdefaultdisplay().getwidth();

int height = wm.getdefaultdisplay().getheight();

方法二:

windowmanager wm1 = this.getwindowmanager();

int width1 = wm1.getdefaultdisplay().getwidth();

int height1 = wm1.getdefaultdisplay().getheight();

方法一與方法二獲取螢幕寬度的方法類似,只是獲取windowmanager 物件時的途徑不同。

方法三:

windowmanager manager = this.getwindowmanager();

displaymetrics outmetrics = new displaymetrics();

manager.getdefaultdisplay().getmetrics(outmetrics);

int width2 = outmetrics.widthpixels;

int height2 = outmetrics.heightpixels;

方法四:

resources resources = this.getresources();

displaymetrics dm = resources.getdisplaymetrics();

float density1 = dm.density;

int width3 = dm.widthpixels;

int height3 = dm.heightpixels;

方法三與方法四類似。

Android開發FAQ集錦!!! 不斷更新

答 谷歌官網的 這個被和諧了,經常上不去,中國的網路大家都是 知道的呵呵 2.drawable hdpi,drawable ldpi,drawable mdpi有什麼區別?答 主要是為了支援多解析度的.hdpi裡面主要放高解析度的,如wvga 480x800 fwvga 480x854 mdpi 裡...

Linux環境應用雜記 不斷更新

scim輸入法 sudo apt get remove scim sudo apt get install scim sudo apt get install scim chinese sudo gedit etc x11 xsession.d 95xinput usr bin scim d xmo...

libuv 不斷更新

initialize the uv async t handle.a null callback is allowed.note that uv async init unlike other libuv functions,immediately starts the handle.to stop...