android - Unwanted extra padding around custom View element -
!!!problem solved!!!
the problem overridden onlayout function after removing code works expected!
i created own view object extending relativelayout, displays applies padding(image bellow) - grey area size of custom element added main xml layout(size expected) , green view inflated element somehow takes padding in accordance height of elements above(as can see on image 2).
why happening? want textview(green part) fill full parent(grey part) noticed has proper size moved down out of screen on bottom.
can me please figure 1 out?
logview.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="top" android:gravity="top" > <textview android:id="@+id/textview1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:background="@color/green" android:text="medium text" android:textappearance="?android:attr/textappearancemedium" /> <imagebutton android:id="@+id/imagebutton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:background="@android:color/darker_gray" android:src="@android:drawable/ic_media_pause" /> </relativelayout> main.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <textview android:id="@+id/statelabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/logbox" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:text="@string/bt_status" tools:context=".mainactivity" /> <com.canlab.carguard.view.logview android:id="@+id/logbox" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:layout_below="@+id/carlabel" android:background="@color/l_blue" /> <textview android:id="@+id/driverlabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:text="Řidič:" android:textappearance="?android:attr/textappearancemedium" /> <textview android:id="@+id/carlabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_below="@+id/driverlabel" android:text="auto:" android:textappearance="?android:attr/textappearancemedium" /> logview.class
public class logview extends relativelayout { private final static string tag = "logview"; private final layoutinflater inflater; private final int maxlines = 100; private boolean scroll = true; private final textview log; private final imagebutton pausebutton; private int = 0; public logview(context context) { super(context); inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service); this.addview(inflater.inflate(r.layout.logview, null)); pausebutton = (imagebutton) this.findviewbyid(r.id.imagebutton1); log = (textview) this.findviewbyid(r.id.textview1); initview(context); this.setscrollbarstyle(scrollbars_inside_overlay); } public logview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service); this.addview(inflater.inflate(r.layout.logview, null)); pausebutton = (imagebutton) this.findviewbyid(r.id.imagebutton1); log = (textview) this.findviewbyid(r.id.textview1); initview(context); } public logview(context context, attributeset attrs) { super(context, attrs); inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service); this.addview(inflater.inflate(r.layout.logview,null)); pausebutton = (imagebutton) this.findviewbyid(r.id.imagebutton1); log = (textview) this.findviewbyid(r.id.textview1); initview(context); } private void initview(context context){ log.settextsize(15); log.settypeface(typeface.monospace); log.setgravity(gravity.bottom); log.setmovementmethod(new scrollingmovementmethod()); } @override protected void onlayout(boolean changed, int l, int t, int r, int b) { // todo auto-generated method stub for(int = 0 ; < getchildcount() ; i++){ getchildat(i).layout(l, t, r, b); } }
Comments
Post a Comment