转自:http://blog.csdn.net/a704755096/article/details/46342689
DPI:每英寸像素数
简单的屏幕分辨率计算方法:
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计算图(mdpi 1dp=1px):
ldpi:1dp=0.75px mdpi:1dp=1px hdpi:1dp=1.5px xhdpi:1dp=2px xxhdpi:1dp=3px xxxhdpi:1dp=4px
Android手机屏幕标准 对应图标尺寸标准 屏幕密度 比例
xxxhdpi 3840*2160 192*192 640 16
xxhdpi 1920*1080 144*144 480 12
xhdpi 1280*720 96*96 320 8
hdpi 480*800 72*72 240 6
mdpi 480*320 48*48 160 4
ldpi 320*240 36*36 120 3
注:android studio mipmap文件夹只存放启动图标icon
http://blog.csdn.net/a704755096/article/details/46342689
1)单个布局xml直接横竖屏切换,不重新加载数据:android:configChanges="orientation|keyboardHidden|screenSize"
2)layout-land和layout-portFragmentActivity重写onRetainNonConfigurationInstance()在onCreate()时判断是否null:
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (data == null) {
- }
- }
安卓图片动画(http://www.open-open.com/lib/view/open1335777066015.html)、点九图工具:
1.打开Android 工程包 SDK文件,tools文件,双击draw9patch.bat
2.弹出的窗口点击 File,点击要编辑的图片open 9patch
3.编辑。鼠标左键:划线 / shift + 鼠标左键:删除划线
4.保存。点击save 9patch