2015-09-04 10 views
15

Yeni Yüzde Destek Kitaplığı, bir boyut xml dosyasındaki Yüzdelik değerine başvurulmasına izin verilmeden yayımlandı.PercentRelativeLayout Yüzde değeri için eksik XML kaynak türü?

<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.PercentFrameLayout/> 

böyle bir şeyi kod edememek: yerine, olduğu

myWidthPercent bir kaynak dosyaları tanımlanır

<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="@percent/myWidthPercent" 
    app:layout_heightPercent="@percent/my/HeightPercent" 
    app:layout_marginTopPercent="@percent/myMarginTophPercent" 
    app:layout_marginLeftPercent="@percent/myMarginLeftPercent"/> 

.

Yanlış mı (başka bir adla özledim mi) veya google'a gönderebileceğimiz bir özellik isteğidir?

+0

bunu nasıl etiketleri kullanıyorsunuz için başvuran

cevap

29

Kullanım yerine yüzde

<resources> 
    <fraction name="myWidthPercent">50%</fraction> 
... 
</resources> 

kesir Ve ilk satırda hata alıyorum gibi

<ImageView 
    app:layout_widthPercent="@fraction/myWidthPercent" 
    app:layout_heightPercent="@fraction/my/HeightPercent" 
    app:layout_marginTopPercent="@fraction/myMarginTophPercent" 
    app:layout_marginLeftPercent="@fraction/myMarginLeftPercent"/> 
+0

Anladım. Tam olarak ihtiyacım olan şey. Teşekkürler Llya. – u2gilles

İlgili konular