DPI:每英寸像素?cái)?shù)
簡(jiǎn)單的屏幕分辨率計(jì)算方法:
DisplayMetrics metrics = this.getResources().getDisplayMetrics();
float density = metrics.density;
int dpi = metrics.densityDpi;
int heightPixels = metrics.heightPixels;
int widthPixels = metrics.widthPixels;
Log.e("---metrics---", "比例:"+density+"dpi:"+dpi+"高像素:"+heightPixels+"寬像素:"+widthPixels);
dp與px計(jì)算圖(mdpi 1dp=1px):
ldpi:1dp=0.75px mdpi:1dp=1px hdpi:1dp=1.5px xhdpi:1dp=2px xxhdpi:1dp=3px xxxhdpi:1dp=4px
注:Android studio mipmap文件夾只存放啟動(dòng)圖標(biāo)icon
屏幕橫豎屏布局切換:
1)單個(gè)布局xml直接
橫豎屏切換胯杭,不重新加載數(shù)據(jù):android:configChanges="orientation|keyboardHidden|screenSize"
layout-land和layout-port
布局
橫豎屏切換往湿,不重新加載數(shù)據(jù):
FragmentActivity重寫
onRetainCustomNonConfigurationInstance()
Activity 重寫
onRetainNonConfigurationInstance()
保存數(shù)據(jù)劈伴,在onCreate()時(shí)判斷
getLastNonConfigurationInstance()
是否null:
更多:安卓圖片動(dòng)畫(http://www.open-open.com/lib/view/open1335777066015.html)的诵、
點(diǎn)九圖工具:
1.打開Android 工程包 SDK文件阔籽,tools文件马靠,雙擊draw9patch.bat
2.彈出的窗口點(diǎn)擊 File篇梭,點(diǎn)擊要編輯的圖片open 9patch
3.編輯赏表。鼠標(biāo)左鍵:劃線 / shift + 鼠標(biāo)左鍵:刪除劃線
4.保存检诗。點(diǎn)擊save 9patch