Alternative to weightSum in RelativeLayout?

会有一股神秘感。 提交于 2019-12-07 02:59:21

问题


I have four TextView items that I want to evenly spread in a horizontal line. This means that all the space in a line must be evenly occupied by the TextView items. Like this:

Previously, I used LinearLayout for this. I had the weightSum as 4 and assigned a layout_weight of 1 to each TextView item. However, this compromises on some functionality I want to implement in my app:

I want to put an EditText item under each of the four TextView items. The EditText items visibility will be set to INVISIBLE first, and then at the touch of a button, the EditTexts will become visible and the visibility of the Textviews will be set to INVISIBLE. This is only possible if I use RelativeLayout

So how do I use RelativeLayout for the four TextView items while evenly occupying all the space?


回答1:


Simply put, you can't. That's why you were using a LinearLayout as the 4 TextViews container.



来源:https://stackoverflow.com/questions/21144691/alternative-to-weightsum-in-relativelayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!