我是初學者,爲android編程。首先我需要我的應用程序將支持2設備手機(480x800)和平板電腦(1280x800)。支持多屏(手機和平板電腦)
我讀了這個,並試圖一步一步做。 Supporting Multiple Screens
所以我創建的文件夾與佈局:
res/layout/firstPage.xml//this is by default phone layout port and land
res/layout-sw720dp/firstPage.xml//this is tablet port layout
res/layout-sw720dp-land/firstPage.xml//this is tablet land layout
我的XML看起來是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_vertical"
android:baselineAligned="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:text="@string/button1" />
<Button
android:id="@+id/button2"
android:text="@string/button2" />
<Button
android:id="@+id/button3"
android:text="@string/button3" />
</LinearLayout>
我不給有關按鈕的詳細信息,因爲在每一個佈局,他們是不同的。
在我的AndroidManifest.xml我有這樣一行:
<supports-screens android:anyDensity="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:largeScreens="true"/>
也許我並不需要爲他人真如果我設置TRU這個anyDensity =「真」
因此,我認爲我做了一切,因爲我應該。但是當我想在平板電腦上測試時,它會默認顯示我的電話佈局。 那麼我錯過了什麼? 或者我還需要做一些編碼?
編輯:
我想我明白爲什麼... 從Android 3.2(API等級13)開始,上述尺寸組已被取消,您應改用SWDP設定限定詞來定義的最小可用寬度您的佈局資源所需。
我的表是3.1,所以它沒有找到佈局? 但如果我想要支持從2.1到4,該怎麼辦?
您給佈局按鈕的layout_height和layout_width佈局的值是多少? – 2012-02-15 12:45:51