3

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 ?

Emir Civas
  • 210
  • 1
  • 9
  • The `TableLayout` should have most of that behavior by default. Can you also post the current layout file or code you used for this table? – user Dec 02 '12 at 12:32
  • @MMohsinNaeem I didn't write any code, just playing with xml. Here's the xml : http://pastie.org/5466343 (Remove background node) :) – Emir Civas Dec 02 '12 at 12:45
  • @Luksprog i just added android:shrinkColumns="*" and android:stretchColumns="*" and it was done. – Emir Civas Dec 02 '12 at 12:46
  • If you solved the problem then post an answer and accept it so the question becomes answered. – user Dec 02 '12 at 13:06
  • @Luksprog "Users with less than 10 reputation can't answer their own question for 8 hours after asking." :( – Emir Civas Dec 02 '12 at 14:00

1 Answers1

7

Solved It! :)

For someone who will try to do this :

open table_layout in layout.xml and add :

android:shrinkColumns="*"
android:stretchColumns="*"
Emir Civas
  • 210
  • 1
  • 9