java - How do I make my buttons fit on screen in Android? -


i have method takes string of text, chops , makes buttons out of words in string. add these horizontal linear layout this:

for (int x = 0; < string.length; x++) {             button word = new button(context);             word.settext(string[x]+"");             mylinearlayout.addview(word);         } 

the problem if string long, buttons go off screen. how make buttons appear on line below instead of jumping off screen? i've been looking solution day couldn't find answer.

thanks!

try this..

   (int x = 0; < string.length; x++) {         button word = new button(context);         word.settext(string[x]+"");         linearlayout.layoutparams left_on = new linearlayout.layoutparams(0, linearlayout.layoutparams.wrap_content,1);         word.setlayoutparams(left_on);         mylinearlayout.addview(word);     } 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -