ui在不同的螢幕畫素或大小中顯示效果可能會不同
1、建議使用盡量使用線性布局和相對布局,基本上不會產生螢幕大小不適應的問題
2、設定控制項寬高的時候使用單位dip(dp),是根據當前裝置大小比例計算出來的
3、文字設定盡量使用sp單位
4、盡量不使用px設定大小
畫素px和dip相互轉換工具,實現兩種單位的相互轉換,達到適配螢幕的目的
工具類:densityutil
1package
cn.itcast.mobilesafe.utils;23
import
android.content.context;45
public
class
densityutil
1314
/**15
* 根據手機的解析度從 px(畫素) 的單位 轉成為 dp
16*/
17public
static
int px2dip(context context, float
pxvalue)
21 }
android螢幕適配
1 配置android應用程式適配在不同的手機上,需要在androidmanifest.xml檔案的manifest標籤中新增子元素 1 2 3 4 5 6 7 8 9 10 manifestxmlns android supports screens android smallscreens tr...
Android螢幕適配
在sdk中的幫助文件中。develpe training best practices supporting multiple screens 這裡有多屏適配的介紹。現做簡單記錄。screen size small 至少 426dp x 320dp normal 至少 470dp x 320dp l...
android螢幕適配
一 關於布局適配 1 不要使用絕對布局 2 盡量使用match parent 而不是fill parent 3 能夠使用權重的地方盡量使用權重 android layout weight 4 如果是純色背景,盡量使用 android 的shape 自定義。5 如果需要在特定解析度下適配,可以在 re...