我一直在測試大多數我的佈局在Galaxy 5 Media Player
上,並且佈局都在尋找我如何在常規layout
文件夾中設計它們。我使用SDK 10
,所以我不使用layout-sw600dp
類型的文件夾,而不是我用/layout
,/layout-large
等我在大屏幕設備上的佈局與大屏幕預覽不匹配
雖然我的佈局看起來罰款銀河5的球員,當我嘗試過其他的設備上,這將是使用,Lenovo Ideapad A1
,觀點是不正確的。我在/layout-large
中爲7「平板電腦創建了一個新的xml文件,但現在預覽中的內容與我的設備上的內容不匹配
我使用RelativeLayout
,但沒有任何內容但有8個按鈕第一個按鈕宣告與底部對齊,則每個以下按鈕被放置在它下面的一個以上,具有marginBottom
參數集
這是爲原始視圖xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/v2"
android:gravity="center_horizontal"
android:orientation="vertical" >
<Button
android:id="@+id/exitButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="36dp"
android:layout_alignParentBottom="true"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_exit" />
<Button
android:id="@+id/findDeviceButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="18dp"
android:layout_above="@id/exitButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_find_device" />
<Button
android:id="@+id/cebusButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="18dp"
android:layout_above="@id/findDeviceButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_cebus" />
<Button
android:id="@+id/operationsButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="18dp"
android:layout_above="@id/cebusButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_operations" />
<Button
android:id="@+id/monitorButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="18dp"
android:layout_above="@id/operationsButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_monitor" />
<Button
android:id="@+id/wavesButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="18dp"
android:layout_above="@id/monitorButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_waves" />
<Button
android:id="@+id/statusButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="18dp"
android:layout_above="@id/wavesButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_status" />
<Button
android:id="@+id/more_parametersButton"
android:layout_width="350dp"
android:layout_height="60dp"
android:layout_marginBottom="18dp"
android:layout_above="@id/statusButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_parameters" />
</RelativeLayout>
當運行此在我的7英寸設備上,這些按鈕很大,並且越過了屏幕的頂部。但是在Eclipse
的預覽中,這些按鈕都很適合屏幕。爲什麼預覽會讓我看到與我所期望的不同的視角?
編輯:
我已經調整了XML文件,使之在我的平板電腦工作。儘管現在預覽看起來更糟,但下面的XML文件會生成我想要的設備上的結果。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/v2"
android:gravity="center_horizontal"
android:orientation="vertical" >
<Button
android:id="@+id/exitButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="30dp"
android:layout_alignParentBottom="true"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_exit" />
<Button
android:id="@+id/findDeviceButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_above="@id/exitButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_find_device" />
<Button
android:id="@+id/cebusButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_above="@id/findDeviceButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_cebus" />
<Button
android:id="@+id/operationsButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_above="@id/cebusButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_operations" />
<Button
android:id="@+id/monitorButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_above="@id/operationsButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_monitor" />
<Button
android:id="@+id/wavesButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_above="@id/monitorButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_waves" />
<Button
android:id="@+id/statusButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_above="@id/wavesButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_status" />
<Button
android:id="@+id/more_parametersButton"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:layout_above="@id/statusButton"
android:textColor="@android:color/white"
android:background="@drawable/sel_button_round"
android:text="@string/main_parameters" />
</RelativeLayout>