日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

android smart scale

發布時間:2025/3/15 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android smart scale 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

<!DOCTYPE html>







<header><p>Jan 4, 2015 ? CoderSimple <a href="http://codersimple.github.io/android/2015/01/04/android-smart-scale.html">原文傳送陣</a></p> </header><article><p>android 設備的尺寸多種多樣,在適配上給開發者帶來了不少的麻煩,為了讓我們的程序能在不同的屏幕尺寸下優雅的顯示,學習一些適配的知識變得尤為重要,這里為了加深印象,在學習中做下總結(寫到后面感覺沒什么好寫的,都是官網的東西,真矛盾,最后還是當練習排版留下來了)。</p>
  • 屬性值
    • 文字大小屬性使用 sp,其他圖像間距使用 dp,避免使用 px
    • 布局盡量使用 wrap_content 和 match_parent 或者 (fill_parent)
  • 布局
    • 杜絕使用 AbsoluteLayout 布局(除非特別需要,但是基本不需要)
  • 布局限定符
    使用方法:layout-尺寸限定符/最小尺寸限定符/main.xml
    • 尺寸限定符(API13 后不推薦使用)
    • 最小尺寸限定符(API13 后推薦使用)
    • 布局別名 由于最小尺寸限定符在 Android 3.2 及之前平臺上無法識別,有時候在使用最小尺寸限定符布局時為了兼容,有必要再創建一個尺寸限定符的布局,我們可以在尺寸限定符的布局文件夾下在放置一份最小尺寸限定符的布局,然而這樣是我們不愿意做的,這樣會造成內存空間的浪費,因此在里只創建一份文件布局,通過布局的引用達到我們想要的效果,以下為官網示例。
      • res/layout/main_twopanes.xml
      • res/values-large/layout.xml:

        <resources><item name="main" type="layout">@layout/main_twopanes</item></resources>
      • res/values-sw600dp/layout.xml:

        <resources><item name="main" type="layout">@layout/main_twopanes</item></resources>
  • 方向限定符
    屏幕的方向分為水平方向 (land) 和豎直方向 (port),使用方法同布局限定符
  • 布局限定符 與 方向限定符 的混合使用
    layout-尺寸限定符/最小尺寸限定符-方向限定符/main.xml
  • 圖片限定符
  • 總而言之,屏幕的適配也就是布局資源的適配,由于涉及基礎知識較多,造成難度的提升,這里給出 官網屏幕適配教程,所有涉及的知識基本上都有了,只要耐心的看完,相信你會有所收獲。


    基礎知識

  • screen size
    • small small screens are at least 426dp x 320dp
    • normal normal screens are at least 470dp x 320dp
    • large large screens are at least 640dp x 480dp
    • xlarge xlarge screens are at least 960dp x 720dp
  • screen desity(3:4:6:8:12:16)
    • ldpi(low) ~ 120dpi
    • mdpi(medium) ~ 160dpi(base line)
    • hdpi(high) ~ 240dpi
    • xhdpi(extra-high) ~ 320dpi
    • xxhdpi(extra-extra-high) ~ 480dpi
    • xxxhdpi(extra-extra-extra-high) ~ 640dpi

      Note: the drawable-xxxhdpi qualifier is necessary only to provide a launcher icon that can appear larger than usual on an xxhdpi device. You do not need to provide xxxhdpi assets for all your app's images

      Some devices scale-up the launcher icon by as much as 25%. For example, if your highest density launcher icon image is already extra-extra-high-density, the scaling process will make it appear less crisp. So you should provide a higher density launcher icon in the drawable-xxxhdpi directory, which the system uses instead of scaling up a smaller version of the icon.

  • orientation
    • land(landscape)
    • port(portrait)
  • Resolution
    • The total number of physical pixels on a screen. When adding support for multiple screens, applications do not work directly with resolution; applications should be concerned only with screen size and density, as specified by the generalized size and density groups.
  • Density-independent pixel (dp or dip)
    • A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way.
    • The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen
    • px = dp * (dpi / 160)
  • screens ranges:

    </article> </div>

    轉載于:https://www.cnblogs.com/codersimple/p/4202398.html

    創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

    總結

    以上是生活随笔為你收集整理的android smart scale的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。