0

I'm setting up a layout, that I'm adding to (via a for-loop) based on a set of objects. The issue is if there are say 3 fields (columns), if the middle field has a longer text length in the first entry than the second... the middle field in the first one will consume a larger width, even if I've already defined a weightSum and a layout_weight for that center column. My question is, when dynamically adding rows like this, how can I ensure that they all end up being the exact same width, as defined in the XML?

RyanInBinary
  • 1,533
  • 3
  • 19
  • 47

2 Answers2

1

Why don't you just set a fixed width?

As in

setWidth(int width)

EDIT:

The formula to convert px to dpi is:

truePixels = DIPs * (device DPI / 160)

Here take a look how to get screen dpi.

Docs about supporting multiple screens.

Community
  • 1
  • 1
Comic Sans MS Lover
  • 1,729
  • 5
  • 26
  • 52
0

If you're using xml layout for rows then:

android:layout_width="0"

If everything is done programmatically then setWidth(0)

pawelzieba
  • 16,082
  • 3
  • 46
  • 72