出现此问题的前提是:在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"/>