Android Horizontal oriented LinearLayout – how to know how many TextViews will fit? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Android Horizontal oriented LinearLayout – how to know how many TextViews will fit? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

My Idea is adding TextViews with rounded corners background to a horizontal LinearLayout, so if next one wouldn’t fit – I will add TextView to another LinearLayout below.

Is there a way to do so? I know it sound like a custom view, but I would like not to bother as much – to adjust height, make click area calculations istead of simple clickListeners

Answer

Sounds like a recyclerview using a flexbox layout https://github.com/google/flexbox-layout with flexWrap turned on.

You could also use is in a static layout as well.

With flexWrap it does all the calculations to see if the “item” can fit on a line and if not starts a new line.

Many examples on the github page.

We are here to answer your question about Android Horizontal oriented LinearLayout – how to know how many TextViews will fit? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji