Android extended LinearLayout height matches parent, but children do not -
i extending linearlayout matching parents height , width. inside linearlayout, inflating view set match parent height , width well. inflated views width matches parent, inflated views height not.
i have tested on 2 devices, 1 running kitkat (api 19), in case problem occurs, , 1 running marshmallow (api 23), in case problem not occur.
this extended linearlayout:
public class messagebackground extends linearlayout { public messagebackground(context context) { this(context, null); } public messagebackground(final context context, attributeset attrs) { super(context, attrs); layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); inflater.inflate(r.layout.message_background_layout, this, true); this.setbackgroundcolor(context.getresources().getcolor(r.color.red)); } }
this inflated xml layout:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:minheight="20dp" android:background="#0000ff"> </relativelayout>
these different results on kitkat , marshmallow:
i have tried several variations try , xml layout match height of linearlayout on kitkat, can't seem find way work. suggestions or reasons why behaviour different helpful.
Comments
Post a Comment