(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的 ...
随机推荐
- nginx 学习笔记【持续更新...】
1.如果在安装过程中出现以下错误 需要安装pcre库 解决方案:yum install pcre 2.如果nginx启动提示端口被占用,则停止该端口的服务再启动nginx,一般为httpd服务 解决方 ...
- 【原】从一个bug浅谈YUI3组件的资源加载
篇前声明:为了不涉及业务细节,篇内信息统一以某游戏,某功能代替 前不久,某游戏准备内测客户端,开发人员测试过程中发现某功能突然不灵了,之前的测试一切ok,没有发现任何异常,第一反应是,游戏内浏览器都是 ...
- PHP发红包程序
//红包算法$total = 20; //红包总金额$num = 10; //红包个数$min = 0.01; //每个人最少能收到0.01 for ($i=1;$i<$num; ...
- 客户端持久化解决方案:indexedDB
客户端持久化解决方案:indexedDB indexedDB适合大量的结构化的数据存储:打开数据库和获取数据对象都是异步的: 需要开启事务,访问的objectStore都要是在开启的事务中. 数据库结 ...
- hive中partition如何使用
1.背景 1.在Hive Select查询中一般会扫描整个表内容,会消耗很多时间做没必要的工作.有时候只需要扫描表中关心的一部分数据,因此建表时引入了partition概念. 2.分区表指的是在创建表 ...
- string和整数转换
tostring(int) fromstring(string ) c++11新方式 stod Convert string to double (function template ) stold ...
- Igor In the Museum(搜搜搜151515151515******************************************************1515151515151515151515)
D. Igor In the Museum time limit per test 1 second memory limit per test 256 megabytes input standar ...
- poj 2728 Desert King(最优比例生成树)
#include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #i ...
- ASP.NET 验证码 不同浏览器 不刷新问题
具体为什么不刷新是缓存机制不同,验证码图片的src或ImageUrl的获取是来自一个文件,由于连接地址没变所以不同内核浏览器有的会认为源没有变,解决办法就是在连接后面加上一个随机参数如可以用JS的Ma ...
- OAuth2 for asp.net web api
在上篇文章中我研究了OpenId及DotNetOpenAuth的相关应用,这一篇继续研究OAuth2. https://github.com/DotNetOpenAuth http://www.cnb ...