Android Creating button dynamically and fill layout

前端 未结 6 1547
长情又很酷
长情又很酷 2021-01-01 05:25

I\'m creating a button dynamically. The number of button is depend on the size of arraylist. the problem is, after creating the button I will add to the layout using addview

6条回答
  •  死守一世寂寞
    2021-01-01 05:45

    There is not a canned layout in the SDK that does exactly what you are aiming for (i.e. lay out as many children horizontally as will fit, then flow to the next line to lay out some more), so you will need to create a custom ViewGroup that accomplishes this purpose. Luckily for you, Romain Guy created one live on-screen during a presentation at Devoxx.

    Here is a link to that presentation video.

    Here is a link to the sample code and slides.

    HTH

提交回复
热议问题