Android Studio 屏幕分辨率适配

android studio进行android 应用屏幕分辨率适配使用建立不同dimens.xml方法,刚开始建立的文件夹都叫 values-1280x720 values-800x400之类的,发现有时候放到不同分辨率的手机上会显示错误,就是高分辨率手机会显示低分辨率的参数值,在网上找了好久也没有找到原因,突发灵感把values-800x400这种显示 改成了values-hdpi这种,问题就没了,android studio也真是坑爹。

手机常见分辨率:
4:3
VGA 640*480 (Video Graphics Array)
QVGA 320*240 (Quarter VGA)
HVGA 480*320 (Half-size VGA)
SVGA 800*600 (Super VGA)
5:3
WVGA 800*480 (Wide VGA)
16:9
FWVGA 854*480 (Full Wide VGA)
HD 1920*1080 High Definition
QHD 960*540
720p 1280*720 标清
1080p 1920*1080 高清
手机:
iphone 4/4s 960*640 (3:2)
iphone5 1136*640
小米1 854*480(FWVGA)
小米2 1280*720

1.2 分辨率对应DPI
“HVGA mdpi”
“WVGA hdpi ”
“FWVGA hdpi ”
“QHD hdpi ”
“720P xhdpi”
“1080P xxhdpi “

一般 mdpi, hdpi,xhdpi,xxhdpi之间的比例为1 : 1.5

values-hdpi中的dimens.xml内容:

    <dimen name="dp1">0.7dpdimen>
    <dimen name="dp2">1.4dpdimen>
    <dimen name="dp3">2dpdimen>
    <dimen name="dp4">2.7dpdimen>
    <dimen name="dp5">3.4dpdimen>
    <dimen name="dp6">4dpdimen>
    <dimen name="dp7">4.7dpdimen>
    <dimen name="dp8">5.4dpdimen>
    <dimen name="dp9">6dpdimen>
    <dimen name="dp10">6.7dpdimen>
    <dimen name="dp11">7.4dpdimen>
    <dimen name="dp12">8dpdimen>
    <dimen name="dp13">8.7dpdimen>
    <dimen name="dp14">9.4dpdimen>
    <dimen name="dp15">10dpdimen>
    <dimen name="dp16">10.7dpdimen>
    <dimen name="dp17">11.4dpdimen>
    <dimen name="dp18">12dpdimen>
    <dimen name="dp19">12.7dpdimen>
    <dimen name="dp20">13.4dpdimen>
    <dimen name="dp21">14dpdimen>
    <dimen name="dp22">14.7dpdimen>
    <dimen name="dp23">15.4dpdimen>
    <dimen name="dp24">16dpdimen>
    <dimen name="dp25">16.7dpdimen>
    <dimen name="dp26">17.4dpdimen>
    <dimen name="dp27">18dpdimen>
    <dimen name="dp28">18.7dpdimen>
    <dimen name="dp29">19.4dpdimen>
    <dimen name="dp30">20dpdimen>
    <dimen name="dp31">20.7dpdimen>
    <dimen name="dp32">21.4dpdimen>
    <dimen name="dp33">22dpdimen>
    <dimen name="dp34">22.7dpdimen>
    <dimen name="dp35">23.4dpdimen>
    <dimen name="dp36">24dpdimen>
    <dimen name="dp37">24.7dpdimen>
    <dimen name="dp38">25.4dpdimen>
    <dimen name="dp39">26dpdimen>
    <dimen name="dp40">26.7dpdimen>
    <dimen name="dp41">27.4dpdimen>
    <dimen name="dp42">28dpdimen>
    <dimen name="dp43">28.7dpdimen>
    <dimen name="dp44">29.4dpdimen>
    <dimen name="dp45">30dpdimen>
    <dimen name="dp46">30.7dpdimen>
    <dimen name="dp47">31.4dpdimen>
    <dimen name="dp48">32dpdimen>
    <dimen name="dp49">32.7dpdimen>
    <dimen name="dp50">33.4dpdimen>
    <dimen name="dp51">34dpdimen>
    <dimen name="dp52">34.7dpdimen>
    <dimen name="dp53">35.4dpdimen>
    <dimen name="dp54">36dpdimen>
    <dimen name="dp55">36.7dpdimen>
    <dimen name="dp56">37.4dpdimen>
    <dimen name="dp57">38dpdimen>
    <dimen name="dp58">38.7dpdimen>
    <dimen name="dp59">39.4dpdimen>
    <dimen name="dp60">40dpdimen>
    <dimen name="dp61">40.7dpdimen>
    <dimen name="dp62">41.4dpdimen>
    <dimen name="dp63">42dpdimen>
    <dimen name="dp64">42.7dpdimen>
    <dimen name="dp65">43.4dpdimen>
    <dimen name="dp66">44dpdimen>
    <dimen name="dp67">44.7dpdimen>
    <dimen name="dp68">45.4dpdimen>
    <dimen name="dp69">46dpdimen>
    <dimen name="dp70">46.7dpdimen>
    <dimen name="dp71">47.4dpdimen>
    <dimen name="dp72">48dpdimen>
    <dimen name="dp73">48.7dpdimen>
    <dimen name="dp74">49.4dpdimen>
    <dimen name="dp75">50dpdimen>
    <dimen name="dp76">50.7dpdimen>
    <dimen name="dp77">51.4dpdimen>
    <dimen name="dp78">52dpdimen>
    <dimen name="dp79">52.7dpdimen>
    <dimen name="dp80">53.4dpdimen>
    <dimen name="dp81">54dpdimen>
    <dimen name="dp82">54.7dpdimen>
    <dimen name="dp83">55.4dpdimen>
    <dimen name="dp84">56dpdimen>
    <dimen name="dp85">56.7dpdimen>
    <dimen name="dp86">57.4dpdimen>
    <dimen name="dp87">58dpdimen>
    <dimen name="dp88">58.7dpdimen>
    <dimen name="dp89">59.4dpdimen>
    <dimen name="dp90">60dpdimen>
    <dimen name="dp91">60.7dpdimen>
    <dimen name="dp92">61.4dpdimen>
    <dimen name="dp93">62dpdimen>
    <dimen name="dp94">62.7dpdimen>
    <dimen name="dp95">63.4dpdimen>
    <dimen name="dp96">64dpdimen>
    <dimen name="dp97">64.7dpdimen>
    <dimen name="dp98">65.4dpdimen>
    <dimen name="dp99">66dpdimen>
    <dimen name="dp100">66.7dpdimen>
    <dimen name="dp105">70dpdimen>
    <dimen name="dp118">78.7dpdimen>
    <dimen name="dp120">80dpdimen>
    <dimen name="dp130">86.7dpdimen>
    <dimen name="dp135">90dpdimen>
    <dimen name="dp140">93.4dpdimen>
    <dimen name="dp142">94.7dpdimen>
    <dimen name="dp150">100dpdimen>
    <dimen name="dp160">106.7dpdimen>
    <dimen name="dp182">121.4dpdimen>
    <dimen name="dp200">133.4dpdimen>
    <dimen name="dp240">160dpdimen>
    <dimen name="dp250">166.7dpdimen>
    <dimen name="dp251">168.4dpdimen>
    <dimen name="dp260">173.4dpdimen>
    <dimen name="dp285">190dpdimen>
    <dimen name="dp370">246.7dpdimen>

values-xhdpi 中dimens.xml文件的内容

    <dimen name="dp1">1dpdimen>
    <dimen name="dp2">2dpdimen>
    <dimen name="dp3">3dpdimen>
    <dimen name="dp4">4dpdimen>
    <dimen name="dp5">5dpdimen>
    <dimen name="dp6">6dpdimen>
    <dimen name="dp7">7dpdimen>
    <dimen name="dp8">8dpdimen>
    <dimen name="dp9">9dpdimen>
    <dimen name="dp10">10dpdimen>
    <dimen name="dp11">11dpdimen>
    <dimen name="dp12">12dpdimen>
    <dimen name="dp13">13dpdimen>
    <dimen name="dp14">14dpdimen>
    <dimen name="dp15">15dpdimen>
    <dimen name="dp16">16dpdimen>
    <dimen name="dp17">17dpdimen>
    <dimen name="dp18">18dpdimen>
    <dimen name="dp19">19dpdimen>
    <dimen name="dp20">20dpdimen>
    <dimen name="dp21">21dpdimen>
    <dimen name="dp22">22dpdimen>
    <dimen name="dp23">23dpdimen>
    <dimen name="dp24">24dpdimen>
    <dimen name="dp25">25dpdimen>
    <dimen name="dp26">26dpdimen>
    <dimen name="dp27">27dpdimen>
    <dimen name="dp28">28dpdimen>
    <dimen name="dp29">29dpdimen>
    <dimen name="dp30">30dpdimen>
    <dimen name="dp31">31dpdimen>
    <dimen name="dp32">32dpdimen>
    <dimen name="dp33">33dpdimen>
    <dimen name="dp34">34dpdimen>
    <dimen name="dp35">35dpdimen>
    <dimen name="dp36">36dpdimen>
    <dimen name="dp37">37dpdimen>
    <dimen name="dp38">38dpdimen>
    <dimen name="dp39">39dpdimen>
    <dimen name="dp40">40dpdimen>
    <dimen name="dp41">41dpdimen>
    <dimen name="dp42">42dpdimen>
    <dimen name="dp43">43dpdimen>
    <dimen name="dp44">44dpdimen>
    <dimen name="dp45">45dpdimen>
    <dimen name="dp46">46dpdimen>
    <dimen name="dp47">47dpdimen>
    <dimen name="dp48">48dpdimen>
    <dimen name="dp49">49dpdimen>
    <dimen name="dp50">50dpdimen>
    <dimen name="dp51">51dpdimen>
    <dimen name="dp52">52dpdimen>
    <dimen name="dp53">53dpdimen>
    <dimen name="dp54">54dpdimen>
    <dimen name="dp55">55dpdimen>
    <dimen name="dp56">56dpdimen>
    <dimen name="dp57">57dpdimen>
    <dimen name="dp58">58dpdimen>
    <dimen name="dp59">59dpdimen>
    <dimen name="dp60">60dpdimen>
    <dimen name="dp61">61dpdimen>
    <dimen name="dp62">62dpdimen>
    <dimen name="dp63">63dpdimen>
    <dimen name="dp64">64dpdimen>
    <dimen name="dp65">65dpdimen>
    <dimen name="dp66">66dpdimen>
    <dimen name="dp67">67dpdimen>
    <dimen name="dp68">68dpdimen>
    <dimen name="dp69">69dpdimen>
    <dimen name="dp70">70dpdimen>
    <dimen name="dp71">71dpdimen>
    <dimen name="dp72">72dpdimen>
    <dimen name="dp73">73dpdimen>
    <dimen name="dp74">74dpdimen>
    <dimen name="dp75">75dpdimen>
    <dimen name="dp76">76dpdimen>
    <dimen name="dp77">77dpdimen>
    <dimen name="dp78">78dpdimen>
    <dimen name="dp79">79dpdimen>
    <dimen name="dp80">80dpdimen>
    <dimen name="dp81">81dpdimen>
    <dimen name="dp82">82dpdimen>
    <dimen name="dp83">83dpdimen>
    <dimen name="dp84">84dpdimen>
    <dimen name="dp85">85dpdimen>
    <dimen name="dp86">86dpdimen>
    <dimen name="dp87">87dpdimen>
    <dimen name="dp88">88dpdimen>
    <dimen name="dp89">89dpdimen>
    <dimen name="dp90">90dpdimen>
    <dimen name="dp91">91dpdimen>
    <dimen name="dp92">92dpdimen>
    <dimen name="dp93">93dpdimen>
    <dimen name="dp94">94dpdimen>
    <dimen name="dp95">95dpdimen>
    <dimen name="dp96">96dpdimen>
    <dimen name="dp97">97dpdimen>
    <dimen name="dp98">98dpdimen>
    <dimen name="dp99">99dpdimen>
    <dimen name="dp100">100dpdimen>
    <dimen name="dp105">105dpdimen>
    <dimen name="dp118">118dpdimen>
    <dimen name="dp120">120dpdimen>
    <dimen name="dp130">130dpdimen>
    <dimen name="dp135">135dpdimen>
    <dimen name="dp140">140dpdimen>
    <dimen name="dp142">142dpdimen>
    <dimen name="dp150">150dpdimen>
    <dimen name="dp160">160dpdimen>
    <dimen name="dp182">182dpdimen>
    <dimen name="dp200">200dpdimen>
    <dimen name="dp240">240dpdimen>
    <dimen name="dp250">250dpdimen>
    <dimen name="dp251">251dpdimen>
    <dimen name="dp260">260dpdimen>
    <dimen name="dp285">285dpdimen>
    <dimen name="dp370">370dpdimen>

我这里开发是以xhdpi中的值为基准,感觉xhdpi中的值到高分辨中可以自动适配,效果还可以,目前就定义了这两个dimens.xml文件

参考:http://blog.csdn.net/guozh/article/details/8954994

你可能感兴趣的:(Android)