2017-05-10 12 views
2

NougatのxmlはmarginRightPercentを無視しています。PercentRelativeLayout margin_percentが動作しない場合があります

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.percent.PercentRelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/container"  
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

     <ImageView 
      android:layout_alignParentRight="true" 
      app:layout_heightPercent="3.45%" 
      app:layout_marginRightPercent="5.07%" 
      app:layout_marginTopPercent="2.85%" 
      app:layout_widthPercent="6.13%" 
      android:scaleType="fitCenter" 
      android:src="@drawable/action_bar_notification"/> 
    . 
    . 
    . 
    . 
    . 
    </android.support.percent.PercentRelativeLayout> 

私は、それが無視されていない私のアプリの他の場所を持っているが、これらの他の場所ではlayout_widthPercentを持っていません。これは6.0でもうまくいきますが、7.0のバグだと思います。

答えて

0

追加android:layout_marginRight="1dp" - 任意の値を指定できます。追加するだけで、app:layout_marginRightPercentのような値が機能します。私は理由を知らない - documentationから、とにかくそれが働くはずだと推測する。

新しいプロジェクトでは、ConstraintLayoutを使用しています。PercentRelativeLayoutはAPI26以降廃止予定です。

関連する問題