2016-08-17 83 views
-1

我在顯示按鈕(上一個(@ id/ib1),下一個(@ id/ib2))時出現問題針對不同的設備。 按鈕略低於設備(摩托羅拉Droid Razr 4.1.2 API級別16)。 XML是如下圖像按鈕在不同設備上的相同位置不顯示,例如:API級別= 16

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/firstLay" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center" 
    android:background="@drawable/bckgrd" 
    android:gravity="center"> 

    <LinearLayout 
     android:id="@+id/layalif" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="10"> 

     <LinearLayout 
      android:id="@+id/layalif1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="3.2" 
      android:orientation="vertical"> 

      <ImageView 
       android:id="@+id/ivalif1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_marginLeft="40dp" 
       android:layout_marginRight="40dp" 
       android:src="@drawable/alifmadstatic" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/layalif2" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="2.3"> 

      <ImageView 

       android:id="@+id/ivalif2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layerType="none" 
       android:scaleType="fitXY" 
       android:src="@drawable/backgroundmove" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/layadd" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="4.5"> 


     </LinearLayout> 


    </LinearLayout> 

    <pro.photex.com.testpoint.drawalifmadaa 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layerType="software" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 


    <ImageButton 
     android:layout_width="64dp" 
     android:layout_height="48dp" 
     android:scaleType="centerInside" 
     android:id="@+id/ib1" 
     android:layout_marginLeft="0dp" 
     android:src="@drawable/previews" 
     android:onClick="btnpreviousclick" 
     android:background="@color/Transparent" 
     android:layout_marginBottom="70dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <ImageButton 
     android:layout_width="64dp" 
     android:layout_height="48dp" 
     android:scaleType="centerInside" 
     android:id="@+id/ib2" 
     android:src="@drawable/next" 
     android:background="@color/Transparent" 
     android:onClick="btnnxtonclick" 
     android:layout_alignTop="@+id/ib1" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 

</RelativeLayout> 

下面是輸出圖像API級16(屏密度1.5):

[enter image description here

下面是輸出圖像API級21(屏密度1.5):

enter image description here

+0

u能張貼截圖也 – Rahul

+0

我附上截圖,請參見鏈接@rah –

+0

這兩個按鈕似乎對齊,我無法弄清楚問題。 – Rahul

回答

0

add

android:layout_alignBottom="@+id/layalif"在兩個ImageButton的

,並刪除

android:layout_marginBottom="70dp" 
+0

感謝這很有幫助@rah –

相關問題