2015-09-04 3 views
15

新しいパーセントサポートライブラリは、ディメンションxmlファイルのPercentage値を参照することを許可せずにリリースされたようです。あるPercentRelativeLayout Percentage値のXMLリソースタイプがありませんか?

、代わりに:myWidthPercentは、リソースファイルに定義されている

<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"/> 

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

はそのような何かをコーディングすることができるという。

私は間違っていますか(私は別の名前でそれを見逃しましたか)、またはGoogleにGoogleに送信できる機能要求ですか?

+0

どのように私は非常に最初の行でエラーを取得していて、あなたがこのタグを使用しない

答えて

29

使用割合の代わりに、パーセント

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

そして

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

入手しました。正確に私が必要なもの。ありがとうLlya。 – u2gilles

関連する問題