簡體   English   中英

不同設備的不同布局參數

[英]different layout parameters for different devices

我在xml文件中創建了一個布局,並在活動頂部顯示了LinearLayout。 我將其寬度設置為fill_parent並將其高度設置為54dp 在具有更大屏幕的設備(如三星Galaxy)上,布局的高度看起來不錯,但在較小的設備上,看起來太大。 無論如何,在不同的屏幕尺寸下布局將具有不同的高度嗎? 我猜想這可以通過dp,dip等來實現,但是我不確定它們到底能做什么

創建layout-normal-hdpilayout-normal-mdpilayout-normal-xhdpi文件夾,並在所有三個文件夾中復制相同的xml,然后根據設備在每個xml上設置不同的高度。 這是遵循的標准技術。 試試這個,您一定會得到期望的結果。

希望這個能對您有所幫助...

res/layout/my_layout.xml             // layout for normal screen size ("default")
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


Low density Small screens QVGA 240x320 

res/layout-small-ldpi
res/layout-small-land-ldpi
Low density Normal screens WVGA400 240x400 (x432)

res/layout-ldpi
res/layout-land-ldpi
Medium density Normal screens HVGA 320x480

res/layout-mdpi
res/layout-land-mdpi
Medium density Large screens HVGA 320x480

res/layout-large-mdpi
res/layout-large-land-mdpi
High density Normal screens WVGA800 480x800 (x854)

res/layout-hdpi
res/layout-land-hdpi
Xoom (medium density large but 1280x800 res)

res/layout-xlarge
res/layout-xlarge-land

如有任何疑問,請評論我...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM