(13)[Xamarin.Android] 不同分辨率下的图片使用概论
原文 [Xamarin.Android] 不同分辨率下的图片使用概论
设计Android App的时候,其尺寸众多也是一个挑战之一。要针对不同尺寸设计Android App时,就要先来了一下dpi(dots per inch,每一英吋的点数量) 与ppi(pixel per square inch,每平方英吋的像素量)计算方式。这一篇研究就来讨论一下在设计Android APP,如何因应不同的尺寸来作呈现。

*假设有一只屏幕规格为3吋而分辨率为(240X320)的手机,那我们就可以推算出它的ppi值, √240⌃2+320⌃2/3=133,所以我们可以得到这个手机的ppi值是133。


res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density

36x36 for low-density
48x48 for medium-density
72x72 for high-density
96x96 for extra high-density
var dp = Resources.DisplayMetrics.Density;
Console.WriteLine ("density = "+ dp);
float scale = getApplicationContext().getResources().getDisplayMetrics().density;
0.75 means low density
1.0 means standard (medium) density
1.5 means high (large) density
2.0 means extra high density

res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
〈supports-screens android:resizeable=["true"| "false"]
android:smallScreens=["true" | "false"]
android:normalScreens=["true" | "false"]
android:largeScreens=["true" | "false"]
android:xlargeScreens=["true" | "false"]
android:anyDensity=["true" | "false"]
android:requiresSmallestWidthDp="integer"
android:compatibleWidthLimitDp="integer"
android:largestWidthLimitDp="integer"/>




- 1.第一个文字卷标上面会在不同的View上显示[手机],[平板],[大平板]用来分辨我们现在到底加载了那一个Layout进来。
- 2.第二个文字卷标是要显示出目前Device的Density,来看看Android目前判断出来的Device Density值。
- 3.而ImageView是用来加载图片,这里Android系统会依据不同的Device分辨率来加载相对应的图片。


- - 分辨率(480x800,240dpi )的Nexus One。
- - 分辨率(1024x600,160dpi)的WSVGA 7.0 Tablet。
- - 分辨率(1024x800,160dpi)的WXGA 10.1 Tablet。
- - 分辨率(1080x1776,480dpi)的Htc new one实机。




- supports-screenssupports-screens
http://developer.android.com/guide/topics/manifest/supports-screens-element.html - Devices and Displays
http://developer.android.com/design/style/devices-displays.html - Supporting Multiple Screens
http://developer.android.com/guide/practices/screens_support.html - Devices and Displays
http://developer.android.com/design/style/devices-displays.html - Part 4 - Creating Resources for Varying Screens
http://docs.xamarin.com/guides/android/application_fundamentals/resources_in_android/part_4_-_creating_resources_for_varying_screens/ - List of displays by pixel density
http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
(13)[Xamarin.Android] 不同分辨率下的图片使用概论的更多相关文章
- Android各分辨率定义的图片规格
我们定义的app图片规格 app图标需要分iphone和android两套 iphone: 名称 Iphone4 Iphone5 手机尺寸 960*640(高*宽) 1136*640 (高*宽) 电池 ...
- Android 不同分辨率下调整界面
Android Settings中有修改Disaply size的界面,通过修改Display size,能够修改屏幕分辨率. 由于修改了屏幕分辨率,有可能导致同一界面在不同的分辨率下显示出错(内容显 ...
- android将drawable下的图片转换成bitmap
将drawable下的图片转换成bitmap 1. Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.xx ...
- Android 将drawable下的图片转换成bitmap、Drawable
将drawable下的图片转换成bitmap . Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.xxx ...
- Xamarin.Android 在VS下调试时提示 In mgmain JNI_OnLoad 程序“Mono”已退出 解决办法
原因是使用了破解版的 Xamarin,调试时不能使用共享库
- 62.Android之各分辨率定义的图片规格
转载:http://www.nljb.net/default/Android%E4%B9%8B%E5%90%84%E5%88%86%E8%BE%A8%E7%8E%87%E5%AE%9A%E4%B9%8 ...
- Xamarin. Android实现下拉刷新功能
PS:发现文章被其他网站或者博客抓取后发表为原创了,给图片加了个水印 下拉刷新功能在安卓和iOS中非常常见,一般实现这样的功能都是直接使用第三方的库,网上能找到很多这样的开源库.然而在Xamarin. ...
- Android复制assets目录下的图片到内存
转自:http://www.chenwg.com/android/android%E5%A4%8D%E5%88%B6assets%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84 ...
- Android应用Icon大小在不同分辨率下定义
http://www.ard9.com/gsjj/204.html 对于Android平台来说,不同分辨率下Icon的大小设计有着不同的要求,对于目前主流的 HDPI即WVGA级别来说,通常hdpi的 ...
随机推荐
- 使用md5判断网站内容是否被篡改
该脚本比较简单,判断网站根目录是否被篡改,如果被篡改把篡改的文件发送到管理员邮箱 #!/bin/bash #author:luodi date:// #use md5 to check web sit ...
- php简单对象与数组的转换
function arrayToObject($e){ if( gettype($e)!='array' ) return; foreach($e as $k=>$v){ ...
- Sublime text3 安装和配置
1.下载安装 首先到http://www.sublimetext.com/3根据你的电脑配置下载对应的安装包,然后不断的点击next,然后blablabla......就可以安装好了.本文是安装por ...
- Android 测试工具集02
User scenario testing for Android(功能性测试框架) Robotium is an Android test automation framework that has ...
- 判断mysqli函数里的sql语句是否有错和影响行数
<?php $mysqli=@new mysqli("localhost", "root", "123456", "xsph ...
- 解决jquery zclip 插件点击无效的问题
使用jquery zclip 用于页面复制文本内容. 首先引入js <script type="text/javascript" src="../js/jquery ...
- mysql 查询重复的(不区分大小写)数据的SQL优化
在mysql中查询不区分大小写重复的数据,往往会用到子查询,并在子查询中使用upper函数来将条件转化为大写.如: select * from staticcatalogue WHERE UPPER( ...
- skynet配置文件
启动skynet需要一个配置文件 我们看下examples/config root = "./" 表示根目录是skynet启动时的目录thread = 8 ...
- 这些年,我收集的JavaScript代码(一)
一.取URL中的参数 function getParameterByName(name) { var match = RegExp('[?&]' + name + '=([^&]*)' ...
- android xml解析 sax
1.简要概述 Android 各种文件都是xml格式的,还有标准的webservice返回的是xml文件,虽然现在的json使用在移动设备端越来越广泛,但是xml格式的解析感觉还是相当必要. 2.sa ...