Keeping Columns Aligned In All Rows In An Android Table

我怕爱的太早我们不能终老 提交于 2020-01-23 10:57:13

问题


I've a problem in Android, that i can't solved no matter what i've tried.

Imagine a tablelayout which has 3 tablerows, and each row two textfields.

Image : Couldn't Add Image Here, Due To New User Restrictions

[Right Now Only Focus On "Showing Data"]

I need to align columns in each row equally.

(meaning : r[ 0 ]c[ 0 ].width = r[ 1]c[ 0 ].width = r[ 2 ]c[ 0 ].width etc..)

However, i've different strings in textviews, and some of them are short, some of them long.

Using 0dp as width and 1 as layout_weight values, doesn't solve my problem. in each row (individually) columns are resized.

[See "Current Behaviour"]

Also, giving constant width values (with px or dp) makes everything constant. I don't want that either..

What i want to do is, set all textfields width in a column (in all rows) equally. According to textview which has the longest text value.

If it's not possible with tablelayout & tablerows, is it possible with listview?

How can i do this ?


回答1:


Solved It! :)

For someone who will try to do this :

open table_layout in layout.xml and add :

android:shrinkColumns="*"
android:stretchColumns="*"


来源:https://stackoverflow.com/questions/13669185/keeping-columns-aligned-in-all-rows-in-an-android-table

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