开发者

Android Fluid Yet Restricted Layout

I have a need where I need to show 3 lines of tags. Tags are just android button elements with some background and padding.

So assume my web service returns 7 tags and their size is unknown unless they are added to the view. Once they are added to the view they result into 4 lines of buttons. You can see in this picture.

Without Text

Android Fluid Yet Restricted Layout

With Text

Android Fluid Yet Restricted Layout

Now I have accomplished this so far using that custom RowLayout and it works. I can just add any number of buttons to that layout and it draws them fluidly. But what I want now is, I give the RowLayout, 7 tags and it decides how many buttons it can fit into 3 lines and put them there and have 2 functions there

  1. nextThree();
  2. prevThree();

Now nextThree() function should be called to ask the RowLayout to draw next series of buttons开发者_JAVA百科 into 3 lines and remove previous one which are already drawn. And prevThree() would be called if the nextThree() was called to move back to those 3 lines of tags. And if nextThree() has 0 buttons next to show then goto the start to show first 3 lines of buttons so it works in a loop.

Another issue is these buttons are not responding to button.setGravity(Gravity.CENTER_VERTICAL); as you can see in the picture above.

Can you give me pointers to solve them?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜