Android - Layout in JAVA File -
as per requirement, should give orientation in horizontal only, if give 3 sentences in 3 text views, if there no space third sentence should come in next line in first position ...
public class mainactivity extends activity {
private linearlayout layout; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); findviewbyid(); linearlayout.layoutparams layoutparams = new linearlayout.layoutparams(layoutparams.wrap_content,layoutparams.wrap_content); layoutparams.setmargins(10, 15, 10, 10); layout.setorientation(linearlayout.horizontal); android.view.viewgroup.layoutparams params; textview tvtextsecond = new textview(this); tvtextsecond.settext("heywhatrudoingtoday"); tvtextsecond.setlayoutparams(layoutparams); tvtextsecond.setbackgroundcolor(color.red); tvtextsecond.settextcolor(color.white); textview tvtextthird = new textview(this); tvtextthird.settext("haiitssundaytowork"); tvtextthird.setlayoutparams(layoutparams); tvtextthird.setbackgroundcolor(color.blue); tvtextthird.settextcolor(color.white); textview tvtextfourth = new textview(this); tvtextfourth.settext("owebullshitruuselessfellow"); tvtextfourth.setlayoutparams(layoutparams); tvtextfourth.setbackgroundcolor(color.yellow); tvtextfourth.settextcolor(color.white); layout.addview(tvtextsecond); layout.addview(tvtextthird); layout.addview(tvtextfourth); } private void findviewbyid() { layout = (linearlayout) findviewbyid(r.id.flowlayout); }
}
linear layout doesn't behave way. if there no space, go out of display area. so, requirement, can't use linear layout here.
Comments
Post a Comment