出現此問題的前提是:在ViewPager+fragment實現的頁面切換,在其中一個fragment的佈局中,根佈局是RelativeLayout;
解決方式:按照網上所說的方法在最後添加一個寬高爲0的View;但此時不行,我上一個佈局如下:
<ImageView
android:id="@+id/iv_right"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="10dp"
/>
添加一個View
<View
android:id="@+id/zero_view"
android:layout_width="0px"
android:layout_height="0px"
android:layout_below="@+id/iv_right_ad"
/>
使view在最後,此時仍然不能解決,注意ImageView中的紅色屬性,需要把layout_marginBottom屬性放到View中才可生效,如下:
<ImageView
android:id="@+id/iv_right"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentRight="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="10dp"
android:layout_above="@+id/zero_view"
/>
<View
android:id="@+id/zero_view"
android:layout_width="0px"
android:layout_height="0px"
android:layout_alignParentBottom="true"/>