Android layout renders wrong on Marshmallow -
i have noticed android app layout broken when displayed on marshmallow. fine on nexus 5 android 5.1.1 renders wrong on nexus 5 , nexus 5x latest version of android.
the layout consist of little triangle (see red part) aligned bottom , above there view (white) should span available height of parent (grey part).
and how renders on android 5.1.1 (nexus 5):
while on android 6.0 (nexus 5 , nexus 5x) is:
the problem looks red view doesn't respect parent alignment (bottom, right) , makes white view (which placed above) disappear.
the simplified layout of grey view , children (i have added background colours see view bounds):
<?xml version="1.0" encoding="utf-8"?> <relativelayout 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" android:background="#777777"> <view android:id="@+id/preview_triangle" android:layout_width="@dimen/preview_triangle_width" android:layout_height="@dimen/preview_triangle_height" android:layout_marginright="@dimen/preview_triangle_margin_right" android:layout_alignparentright="true" android:layout_alignparentbottom="true" android:background="#ff0000"/> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/preview_triangle" android:orientation="horizontal"> <view android:layout_width="@dimen/preview_margin_horizontal" android:layout_height="match_parent"/> <framelayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:padding="3dp" android:background="@drawable/round_rectangle_white_radius_3dp"> <webview android:id="@+id/preview_webview" android:layout_width="match_parent" android:layout_height="match_parent"/> </framelayout> <framelayout android:id="@+id/preview_close" android:layout_width="@dimen/preview_margin_horizontal" android:layout_height="@dimen/preview_margin_horizontal"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left|top" android:layout_marginleft="@dimen/preview_close_margin_left" android:src="@drawable/icn_close" android:contentdescription="@null"/> </framelayout> </linearlayout> </relativelayout>
the above layout placed separate preview.xml file , included main layout this:
<include android:id="@+id/fragment_main_loyalty_preview_container" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@id/fragment_main_loyalty_logo_container" android:layout_above="@id/fragment_main_loyalty_buttons_container" android:layout_margintop="@dimen/fragment_main_loyalty_preview_container_margin_top" android:layout_marginbottom="@dimen/fragment_main_loyalty_preview_container_margin_bottom" android:visibility="visible" layout="@layout/preview"/>
update
the problem disappears if replace hosting scrollview framelayout or so.
i don't why intermediary parent renders fine , child affected top parent :)
and situation can reproduced inside eclipse switching target api in designer.
update - simplified test case
below simplest layout able create , reproduce problem. red area should placed between green , blue ones. height of red area should match space available between green , blue views there view (see @id/margin_placeholder) height affects distance between these two.
inside red area wanted put white view @ bottom of red area. , little white fellow renders different way on android 6.0:
<scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <framelayout android:id="@+id/top" android:layout_width="match_parent" android:layout_height="90dp" android:layout_margintop="10dp" android:background="#007700"/> <view android:id="@+id/margin_placeholder" android:layout_width="match_parent" android:layout_height="100dp" android:layout_below="@id/top"/> <framelayout android:id="@+id/bottom" android:layout_width="match_parent" android:layout_height="90dp" android:layout_below="@id/margin_placeholder" android:background="#000077"/> <relativelayout android:id="@+id/middle" android:layout_width="match_parent" android:layout_height="0dp" android:layout_below="@id/top" android:layout_above="@id/bottom" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:background="#770000"> <view android:layout_width="16dp" android:layout_height="8dp" android:layout_marginright="16dp" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:background="#ffffff"/> </relativelayout> </relativelayout> </scrollview>
it renders fine if upgrade targetsdkversion 16 20.
Comments
Post a Comment