<TextView
android:layout_height="wrap_content"
android:id="@+id/LineNumberTextView"
android:hint="Number"
android:textSize="15sp"
android:layout_width="wrap_content"
android:paddingRight="10sp">
</TextView>
The above code creates a wrong view: when the text is replaced (in code) to a short (1-3 digits) number, the view width stays about 6 characters - resulting in way too much padding. This problem occurs in some other places in the application too. One option is to set the hint to 1-3 characters - but this seems ugly, and doesn't solve the problem for too-long text (which also suffers from hint width problems). Therefore, I'm looking for a more elegant solution (which does not require recalculating width on each change), if there is one.
BTW, the input text is set exactly once for each occurrence of this layout, when loading it into some list view (but it's dynamic and unknown when loading the application). Problem is most severe in android 2.1, but appears in some other platforms too.