2016-03-29 23 views
-1

Farklı ekran boyutlarında aynı görüntü mutlak pozisyonuna nasıl sahip olabilirim?Farklı ekran boyutlarında aynı mutlak konum Android imageview

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000"> 
     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scrollbars="vertical" 
      android:id="@+id/road" 
      android:src="@drawable/road" /> 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/car" 
      android:src="@drawable/car" 
      android:layout_marginLeft="112dp" 
      android:layout_marginTop="168dp" /> 
    </RelativeLayout> 

Araba konumu farklı ekran boyutları için aynı değil.

cevap

1

Sen , çünkü bakmak tüm ekranda büyük yükseklik ve procentege tarafından marjı görünümlerinizin elbette zor aynı ve değildir genişliği ayarlayabilirsiniz bu library ile google kütüphanesini PercentRelativeLayout kullanabilirsiniz kodlamak için. İşte örnek: Googlehttps://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html ederek build.gradle

dependencies { 
    compile 'com.android.support:percent:23.2.0' 
} 

Resmi belgeler içinde

Umut dava için bu yardım bu satırı eklemelisiniz

<android.support.percent.PercentRelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    <ImageView 
     app:layout_widthPercent="50%" 
     app:layout_heightPercent="50%" 
     app:layout_marginTopPercent="25%" 
     app:layout_marginLeftPercent="25%"/> 
</android.support.percent.PercentRelativeLayout> 

!

İlgili konular