2012-07-24 21 views
2

我正在開發一個多屏Android 2.2.2應用程序。Galaxy Nexus是一款小型,正常,大型或X大型設備嗎?

爲了測試不同的屏幕尺寸,我使用日食(朱諾釋放)圖形佈局。這是我的。

main_layout.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/no_conectado" > 

    <TextView 
     android:id="@+id/labelSelGateName" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="@dimen/labelSelGateName_marginTop" 
     android:gravity="center_horizontal" 
     android:textSize="@dimen/labelSelGateName_textsize" /> 


    <TextView 
     android:id="@+id/labelSelOpened" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/labelSelGateName" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="@dimen/labelSelOpened_marginTop" 
     android:gravity="center_horizontal" 
     android:textSize="@dimen/labelSelOpened_textsize" /> 

    <ProgressBar 
     android:id="@+id/indicatorActivityView" 
     android:layout_width="@dimen/indicatorActivityView_height" 
     android:layout_height="@dimen/indicatorActivityView_width" 
     android:layout_below="@+id/labelSelOpened" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="@dimen/indicatorActivityView_marginTop" /> 

    <ImageButton 
     android:id="@+id/btnMyGates" 
     android:layout_width="@dimen/btnMyGates_width" 
     android:layout_height="@dimen/btnMyGates_height" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/indicatorActivityView" 
     android:layout_marginLeft="@dimen/btnMyGates_marginLeft" 
     android:layout_marginTop="@dimen/btnMyGates_marginTop" 
     android:background="@null" 
     android:contentDescription="@string/layout_empty" 
     android:onClick="onGateClick" /> 

    <ImageButton 
     android:id="@+id/btnOpen" 
     android:layout_width="@dimen/btnOpen_width" 
     android:layout_height="@dimen/btnOpen_height" 
     android:layout_alignTop="@+id/btnMyGates" 
     android:layout_centerHorizontal="true" 
     android:background="@null" 
     android:contentDescription="@string/layout_empty" 
     android:onClick="onOpenDoorClick" /> 


    <ImageButton 
     android:id="@+id/btnClose" 
     android:layout_width="@dimen/btnClose_width" 
     android:layout_height="@dimen/btnClose_height" 
     android:layout_alignBottom="@+id/btnMyGates" 
     android:layout_alignLeft="@+id/btnOpen" 
     android:layout_marginBottom="@dimen/btnClose_marginBottom" 
     android:background="@null" 
     android:contentDescription="@string/layout_empty" 
     android:onClick="onCloseDoorClick" /> 

    <ImageButton 
     android:id="@+id/btnOptions" 
     android:layout_width="@dimen/btnOptions_width" 
     android:layout_height="@dimen/btnOptions_height" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@+id/btnMyGates" 
     android:layout_marginRight="@dimen/btnOptions_marginRight" 
     android:background="@null" 
     android:contentDescription="@string/layout_empty" 
     android:onClick="onOptionClick" /> 

    <ImageButton 
     android:id="@+id/btnFaqs" 
     android:layout_width="@dimen/btnFaqs_width" 
     android:layout_height="@dimen/btnFaqs_height" 
     android:layout_marginTop="@dimen/btnFaqs_marginTop" 
     android:layout_toLeftOf="@+id/btnOptions" 
     android:layout_below="@+id/btnClose" 
     android:background="@null" 
     android:contentDescription="@string/layout_empty" 
     android:onClick="onFAQClick" /> 

    <ImageButton 
     android:id="@+id/btnInfo" 
     android:layout_width="@dimen/btnInfo_width" 
     android:layout_height="@dimen/btnInfo_height" 
     android:layout_alignLeft="@+id/btnOptions" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="@dimen/btnInfo_marginLeft" 
     android:background="@null" 
     android:contentDescription="@string/layout_empty" 
     android:onClick="onInfoClick" /> 

</RelativeLayout> 

dimens.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <dimen name="labelSelGateName_marginTop">40dp</dimen> 
    <dimen name="labelSelGateName_textsize">14sp</dimen> 

    <dimen name="labelSelOpened_marginTop">0dp</dimen> 
    <dimen name="labelSelOpened_textsize">14sp</dimen> 

    <dimen name="indicatorActivityView_width">20dp</dimen> 
    <dimen name="indicatorActivityView_height">20dp</dimen> 
    <dimen name="indicatorActivityView_marginTop">28dp</dimen> 

    <dimen name="btnMyGates_width">70dp</dimen> 
    <dimen name="btnMyGates_height">110dp</dimen> 
    <dimen name="btnMyGates_marginLeft">29dp</dimen> 
    <dimen name="btnMyGates_marginTop">60dp</dimen> 

    <dimen name="btnOpen_width">90dp</dimen> 
    <dimen name="btnOpen_height">55dp</dimen> 

    <dimen name="btnClose_width">90dp</dimen> 
    <dimen name="btnClose_height">50dp</dimen> 
    <dimen name="btnClose_marginBottom">0dp</dimen> 

    <dimen name="btnOptions_width">70dp</dimen> 
    <dimen name="btnOptions_height">110dp</dimen> 
    <dimen name="btnOptions_marginRight">30dp</dimen> 

    <dimen name="btnFaqs_width">110dp</dimen> 
    <dimen name="btnFaqs_height">70dp</dimen> 
    <dimen name="btnFaqs_marginTop">10dp</dimen> 

    <dimen name="btnInfo_width">110dp</dimen> 
    <dimen name="btnInfo_height">60dp</dimen> 
    <dimen name="btnInfo_marginLeft">14dp</dimen> 
</resources> 

我有四個dimens.xml在這些文件夾:values-smallvalues-normalvalues-largevalues-xlarge

有了這些文件,它在Nexus One,7in WSVGA Tablet10.1in WXGA Tablet看起來不錯。然而,它在Galaxy Nexus5.4 FWVGA,5.1 WVGA4.7in WXGA中看起來不太好。

當我說它看起來不太好,我的意思是說,每個TextView,ImageButton等已經移動,他們不在正確的位置。

我需要更多文件嗎?

+0

您定位的SDK版本是什麼? – 2012-07-24 18:53:55

+0

@AlexLockwood android:minSdkVersion =「8」android:targetSdkVersion =「15」 – VansFannel 2012-07-24 18:55:16

回答

0

Galaxy Nexus擁有normal屏幕(其分辨率爲1280 x 720),並具有xhdpi密度。

+0

我使用eclipse圖形佈局測試它,它看起來不太好。我需要做其他事嗎? – VansFannel 2012-07-24 19:17:12

+0

我有一個Galaxy Nexus ...如果您感覺舒服,您可以[** email **](http://www.androiddesignpatterns.com/p/contact.html)我.apk文件,我可以發送給您它看起來像一個截圖。這可能是一個日食錯誤,但你可能應該在真實的設備上測試它,以確保它。 (我不會判斷,我保證:P)。 – 2012-07-24 21:19:26

+0

我已經問了關於'Galaxy Nexus'的這個問題:http://stackoverflow.com/questions/11779002/how-to-set-up-layout-to-galaxy-nexus – VansFannel 2012-08-02 14:36:30

0

星系連線(和星系s3和htc一個x)具有正常的屏幕尺寸,具有xhdpi密度。

參考:

http://www.youtube.com/watch?feature=player_detailpage&v=PwC1OlJo5VM#t=3047s

+0

我使用eclipse圖形佈局測試它,它看起來不太好。我需要做其他事嗎? – VansFannel 2012-07-24 19:17:42

+0

不指望日食的視覺編輯器。它通常是好的,但有時它可能會給出錯誤的結果。更好地信任仿真器,當然還有真正的設備。 – 2012-07-24 20:19:55

+0

我已經提出了關於'Galaxy Nexus'的這個問題:http://stackoverflow.com/questions/11779002/how-to-set-up-layout-to-galaxy-nexus – VansFannel 2012-08-02 14:37:08

1

我覺得這是Android的最初設計的限制 - 它的XML佈局不允許指定類似於HTML表,即佈局而不%的基或類似表格的佈局確切的尺寸。

「重量」屬性是不是一種選擇,因爲當我嘗試指定任意佈局,Eclipse的告訴我說:「嵌套的權重是壞的表現」

預選賽都沒有一個好的架構師解決方案,以及因爲有兩個不同的設備可能會在相同的「屏幕密度」對下獲得認證,例如HTC One S/HTC One X.這就是爲什麼Google重新設計它在3.x中引入swdp限定符的原因。

對於Android 2.3,您可以創建一個針對480x800優化的「默認」UI並將其佈置在屏幕中心。它在540x960和更高屏幕上看起來會更小,但仍然沒有損壞。