i implemented custom view can paint. want set match_parent, fills screen independent of screen orientation. when change orientation landscape fills 50% of width.
i changed onmeasure() there no effect:
public class drawscreen extends view{ @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { super.onmeasure(widthmeasurespec, heightmeasurespec); if(context.getresources().getconfiguration().orientation==configuration.orientation_landscape){ setmeasureddimension(screenwidth, screenheight); }else{ setmeasureddimension(screenheight, screenwidth); } } } public class myservice extends service{ ... windowmanager.addview(toolbox, params); }
you try following:
final drawscreen view = new drawscreen(...); final layoutparams lp = new layoutparams(match_parent, match_parent); view.setlayoutparams(lp);