My Tablet app shows a ListView with multiple TextViews in each line item (using custom cursor adapter). I have around 6-7 columns, What is the best way to give equal spaces to all columns?
Right now I tried:
- Same weight on every TextView. But this is never properly aligned.
-
Used max width along with 1st, still no luck, one can easily overflow and push the next one to right.
<TextView android:layout_width="20dp" android:layout_height="wrap_content" android:layout_margin="5dp" android:layout_weight="1" android:text="column 1" android:textSize="22sp" />
Weights are fine, but you have to set
android:layout_widthto0dpevery time you use a layout weight, else your views may not be scaled properly.Also, don’t mix fixed widths with layout weights. If you choose to use weights, use them everywhere in your row layout.