2014-09-23 62 views
0

我正在完成應用程序的開發並將其發送到具有不同設備的beta測試人員。迄今爲止這麼好,除了一臺使用Android 4.4.2的索尼Experia Z1的測試儀外,其他所有功能都完美無缺。他報告說,他無法在屏幕上看到兩個圖像按鈕(請參閱上面的值行和底部的撥號程序之間截圖上缺少的按鈕)。所有其他測試者,不管他們的設備和分辨率如何,都不會報告此類問題。這只是一個用戶。任何幫助爲什麼會發生?我不得不削減下面的XML代碼,因爲字符限制的,兩個下撥號行是不是在那裏...Android:UI項目在某些具有相同分辨率的設備上不可見

編輯:缺少行是在下面的代碼

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/Calculator" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".Calculator"> 

<LinearLayout 
    android:id="@+id/valueRows" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:orientation="vertical" 
    android:weightSum="100"> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:gravity="center"> 


     <LinearLayout 
      android:id="@+id/TopRow" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:weightSum="50" 
      android:baselineAligned="false"> 


      <RelativeLayout 
       android:id="@+id/heatSector" 
       android:layout_width="fill_parent" 
       android:layout_height="50dp" 
       android:layout_marginRight="1dp" 
       android:layout_weight="25" 
       android:background="@android:color/holo_green_dark"> 


       <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_marginLeft="35dp"> 

        <TextView 
         android:id="@+id/heatValue" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:text="0.25" 
         android:textColor="@android:color/white" 
         android:textSize="20sp" 
         android:textStyle="bold" 
         android:typeface="normal" /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/heatValue" 
         android:layout_centerInParent="true" 
         android:layout_marginTop="-6dp" 
         android:text="W/mm2" 
         android:textColor="@android:color/white" 
         android:textSize="10sp" /> 

       </RelativeLayout> 

      </RelativeLayout> 

      <RelativeLayout 
       android:id="@+id/ohmSector" 
       android:layout_width="fill_parent" 
       android:layout_height="50dp" 
       android:layout_marginLeft="1dp" 
       android:layout_weight="25" 
       android:background="@android:color/holo_red_dark"> 

       <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_marginRight="35dp"> 

        <TextView 
         android:id="@+id/itemOhmValue" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:text="0.57" 
         android:textColor="@android:color/white" 
         android:textSize="20sp" 
         android:textStyle="bold" 
         android:typeface="normal" /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/itemOhmValue" 
         android:layout_centerInParent="true" 
         android:layout_marginTop="-6dp" 
         android:text="Ohm" 
         android:textColor="@android:color/white" 
         android:textSize="10sp" /> 

       </RelativeLayout> 

      </RelativeLayout> 


     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/BottomRow" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/TopRow" 
      android:layout_marginTop="2dp" 
      android:weightSum="50" 
      android:baselineAligned="false"> 


      <RelativeLayout 
       android:id="@+id/ampSector" 
       android:layout_width="fill_parent" 
       android:layout_height="50dp" 
       android:layout_marginRight="1dp" 
       android:layout_weight="25" 
       android:background="@android:color/holo_blue_dark"> 

       <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_marginLeft="35dp"> 

        <TextView 
         android:id="@+id/ampValue" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:text="15.75" 
         android:textColor="@android:color/white" 
         android:textSize="20sp" 
         android:textStyle="bold" 
         android:typeface="normal" /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/ampValue" 
         android:layout_centerInParent="true" 
         android:layout_marginTop="-6dp" 
         android:text="Amps" 
         android:textColor="@android:color/white" 
         android:textSize="10sp" /> 

       </RelativeLayout> 

      </RelativeLayout> 

      <RelativeLayout 
       android:id="@+id/wattSector" 
       android:layout_width="fill_parent" 
       android:layout_height="50dp" 
       android:layout_marginLeft="1dp" 
       android:layout_weight="25" 
       android:background="@android:color/holo_orange_dark"> 

       <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_marginRight="35dp"> 

        <TextView 
         android:id="@+id/itemWattsValue" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:text="150" 
         android:textColor="@android:color/white" 
         android:textSize="20sp" 
         android:textStyle="bold" 
         android:typeface="normal" /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/itemWattsValue" 
         android:layout_centerInParent="true" 
         android:layout_marginTop="-6dp" 
         android:text="Watts" 
         android:textColor="@android:color/white" 
         android:textSize="10sp" /> 

       </RelativeLayout> 
      </RelativeLayout> 

     </LinearLayout> 

     <ImageButton 
      android:id="@+id/helpButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:background="@android:color/transparent" 
      android:src="@drawable/help" 
      android:onClick="showHelp" /> 

     <ImageView 
      android:id="@+id/heatSymbol" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="9dp" 
      android:layout_marginTop="2dp" 
      android:src="@drawable/flame" /> 

     <ImageView 
      android:id="@+id/ohmSymbol" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_marginTop="5dp" 
      android:src="@drawable/ohm" /> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/heatSymbol" 
      android:layout_marginLeft="2dp" 
      android:layout_marginTop="14dp" 
      android:src="@drawable/amp" /> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_below="@id/ohmSymbol" 
      android:layout_marginTop="13dp" 
      android:src="@drawable/wattsymbol" /> 


    </RelativeLayout> 

</LinearLayout> 
中段的XML的
<LinearLayout 
    android:id="@+id/wickRow" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/valueRows" 
    android:layout_marginTop="10dp" 
    android:gravity="center_vertical" 
    android:baselineAligned="false" 
    > 

    <RelativeLayout 
     android:id="@+id/cottonElement" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center"> 


     <ImageButton 
      android:id="@+id/cottonButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:layout_marginRight="-40dp" 
      android:background="@android:color/transparent" 
      android:onClick="changeCotton" 
      android:src="@drawable/cotton" /> 


    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/meshElement" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center"> 


     <ImageButton 
      android:id="@+id/meshButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:layout_marginLeft="-40dp" 
      android:background="@android:color/transparent" 
      android:onClick="changeMesh" 
      android:src="@drawable/mesh" /> 


    </RelativeLayout> 

</LinearLayout> 
<LinearLayout 
    android:id="@+id/parameterRowTop" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/wickRow" 
    android:layout_marginTop="5dp" 
    android:gravity="center_vertical" 
    android:baselineAligned="false"> 


    <RelativeLayout 
     android:id="@+id/coilDiameterElement" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center"> 

     <ImageView 
      android:id="@+id/coilDiameterImage" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:src="@drawable/coildiameter" /> 

     <TextView 
      android:id="@+id/itemCoilDiameterValue" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/coilDiameterImage" 
      android:layout_centerInParent="true" 
      android:layout_marginBottom="20dp" 
      android:clickable="false" 
      android:text="2.4" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#ffffffff" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/coilDiameterUnit" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="50dp" 
      android:clickable="false" 
      android:text="mm" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#ffffffff" 
      android:textSize="10sp" /> 

     <ImageButton 
      android:id="@+id/coilDiameterPlus" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/coilDiameterImage" 
      android:layout_alignRight="@+id/coilDiameterImage" 
      android:layout_marginRight="-1dp" 
      android:background="@android:color/transparent" 
      android:onClick="coilDiameterPlusButton" 
      android:src="@drawable/plusbutton" /> 

     <ImageButton 
      android:id="@+id/coilDiameterMinus" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/coilDiameterImage" 
      android:layout_alignLeft="@+id/coilDiameterImage" 
      android:layout_marginLeft="-1dp" 
      android:background="@android:color/transparent" 
      android:onClick="coilDiameterMinusButton" 
      android:src="@drawable/minusbutton" /> 


    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/wireDiameterElement" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dp" 
     android:layout_weight="1" 
     android:gravity="center"> 

     <ImageView 
      android:id="@+id/wireDiameterImage" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:src="@drawable/wirediameter" /> 

     <TextView 
      android:id="@+id/itemWireDiameterValue" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:clickable="false" 
      android:text="0.32" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#ffffffff" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/wireDiameterUnit" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="50dp" 
      android:clickable="false" 
      android:text="mm" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#ffffffff" 
      android:textSize="10sp" /> 

     <ImageButton 
      android:id="@+id/wireDiameterPlus" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/wireDiameterImage" 
      android:layout_alignRight="@+id/wireDiameterImage" 
      android:layout_marginRight="-1dp" 
      android:background="@android:color/transparent" 
      android:onClick="wireDiameterPlusButton" 
      android:src="@drawable/plusbutton" /> 

     <ImageButton 
      android:id="@+id/wireDiameterMinus" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/wireDiameterImage" 
      android:layout_alignLeft="@+id/wireDiameterImage" 
      android:layout_marginLeft="-1dp" 
      android:background="@android:color/transparent" 
      android:onClick="wireDiameterMinusButton" 
      android:src="@drawable/minusbutton" /> 


    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/wrapsElement" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dp" 
     android:layout_weight="1" 
     android:gravity="center"> 

     <ImageView 
      android:id="@+id/wrapsImage" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:src="@drawable/wraps" /> 

     <TextView 
      android:id="@+id/wrapsValue" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:clickable="false" 
      android:text="6.0" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="#ffffffff" 
      android:textStyle="bold" /> 

     <ImageButton 
      android:id="@+id/wrapsPlus" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/wrapsImage" 
      android:layout_alignRight="@+id/wrapsImage" 
      android:layout_marginRight="-1dp" 
      android:background="@android:color/transparent" 
      android:onClick="wrapsPlusButton" 
      android:src="@drawable/plusbutton" /> 

     <ImageButton 
      android:id="@+id/wrapsMinus" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/wrapsImage" 
      android:layout_alignLeft="@+id/wrapsImage" 
      android:layout_marginLeft="-1dp" 
      android:background="@android:color/transparent" 
      android:onClick="wrapsMinusButton" 
      android:src="@drawable/minusbutton" /> 


    </RelativeLayout> 


</LinearLayout> 

. 
. 
. 
. 

Should Be/Normal Screen

Faulty Screen

回答

0

各位可能會遇到類似的問題,在這裏我的解決問題的辦法:

我沒有取下內RelativeLayout的,只是把外的LinearLayout內我的兩個按鈕。爲後者添加了一個權重總和,然後爲每個按鈕添加一個權重...就像一個魅力:

<LinearLayout 
    android:id="@+id/wickRow" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/valueRows" 
    android:layout_marginTop="10dp" 
    android:gravity="center_vertical" 
    android:baselineAligned="false" 
    android:orientation="horizontal" 
    android:weightSum="2" 
    > 




     <ImageButton 
      android:id="@+id/cottonButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:layout_marginRight="-40dp" 
      android:background="@android:color/transparent" 
      android:onClick="changeCotton" 
      android:src="@drawable/cotton" 
      android:layout_weight="1"/> 




     <ImageButton 
      android:id="@+id/meshButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:layout_marginLeft="-40dp" 
      android:background="@android:color/transparent" 
      android:onClick="changeMesh" 
      android:src="@drawable/mesh" 
      android:layout_weight="1"/> 




</LinearLayout> 
0

它不僅決定了佈局資源的分辨率,但許多人都可以。

請仔細閱讀 - http://developer.android.com/guide/practices/screens_support.html

你應該爲你的UI的精確控制,創建特定的屏幕資源。

根據屏幕最小寬度以及不同方向,有很多文件夾。

例如 -

  • 佈局sw360dp - 用最小寬度任何方位360dp

  • 佈局sw360dp-土地xhdpi - 只爲景觀帶最小寬度 360dp和xhdpi設備

  • 佈局sw600dp土地 - 只爲景觀帶最小寬度爲600 dp
  • 佈局sw600dp-土地tvdpi - 只爲景觀帶最小寬度 爲600 dp和tvdpi設備

  • layout-sw720dp-land - 僅適用於最小寬度720dp的景觀

  • 佈局sw360dp端口 - 僅適用於人像與最小寬度720dp

還有更多..

請檢查您的要求,並放在適當的佈局文件夾的佈局文件。

注:

Xperia Z1的物理密度441 ppi所以它落入xxhdpi桶。

例如 - mdpi (160 dpi)hdpi (240 dpi)xhdpi (320 dpi)xxhdpi (480 dpi)

所以我們有公式:px = dp * (dpi/160) or dp = px/(dpi/160)

在這種情況下,dpi = 480 and px = 1080這樣:

dp = 1080/(480/160) = 1080/3 = 360

所以你應該使用 -

layout-sw360dp爲Xperia Z1。

+0

感謝您的建議,我不知道這應該如何雖然解決我的問題,或者還好說,你說我應該把我的XML的精確副本到一個特殊的文件夾?如果是,那麼應該改變什麼? – CRE8IT 2014-09-23 14:46:27

相關問題