Android Views Are Not As Tall As Specified -
i using relativelayout position views @ precise locations on screen. works expected when using view say, draws rectangle. when using android views edittext, drawn shorter specified 8 units. clicking outside of drawn edittext (but within parameters specified relativelayout) will, in fact, hit edittext.
here code illustrate mean:
package com.drawdemo; import android.app.activity; import android.content.context; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.os.bundle; import android.view.view; import android.widget.edittext; import android.widget.relativelayout; public class drawdemo extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); relativelayout l = new relativelayout(this); relativelayout.layoutparams lp = new relativelayout.layoutparams(100,100); lp.leftmargin = 50; lp.topmargin = 50; demoview demoview = new demoview(this); l.addview(demoview, lp); edittext edittext = new edittext(this); l.addview(edittext, lp); setcontentview(l); } private class demoview extends view { public demoview(context context) { super(context); } @override protected void ondraw(canvas canvas) { super.ondraw(canvas); paint paint = new paint(); paint.setstyle(paint.style.fill); paint.setcolor(color.green); canvas.drawpaint(paint); } } }
if execute this, notice edittext noticeably shorter rectangle. i've tried mucking onmeasure, setminimumxxx, , else can think of. far, thing works level of success add 8 or pixels height (8 seems work better trying percentage of height).
next task step source wondering if has solved this.
thanks.
it's because of actual edittext background image that's used. buttons same way, reason google decided draw 9-patch background images transparent padding pixels. really, solution, if it's problem, draw own 9-patch, or modify existing android 9-patch remove pixels.
Comments
Post a Comment