Hello,
Do you want to achieve the result like FlexboxLayout?
If so, you can search this nugget package management in VS.
If you want to write it by yourself, you create a custom view that extends ViewGroup. You need to override onMeasure
and onLayout
method. Because onMeasure
and onLayout
methods are not achieved in ViewGroup
.
OnMeasure
method will measure himself and child Controls’ width and height. All child controls will be measured recursively.
OnLayout
method, you can achieve the inline and newline in OnLayout
method, for example, you can get all child controls by View child = GetChildAt(i);
and iterate over them. If all of controls width over the measured ViewGroup’s width, we can have a newline.
For more details, you can refer to this thread.
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.