I just want a simple non-editable text label but there doesn't seem to be a widget explicitly for it. The closest thing seems to be a android.widget.TextView. But the documentation says a "TextView is a complete text editor". That seems like overkill for a simple label. I don't want to bloat my application. Is there a more appropriate widget?
Or am I approaching this the wrong way? For example, let's say I'm building a settings screen, is there a layout I should choose which gives me labels for the properties so I don't have to specify widgets for the labels?
It is TextView. It displays text to the user.
Label. Labels are components used to show text. A label displays text which is specified by the Text property.
In android, we can set the text of TextView control either while declaring it in Layout file or by using setText() method in Activity file.
ems is a unit of measurement. The name em was originally a reference to the width of the capital M. It sets the width of a TextView/EditText to fit a text of n 'M' letters regardless of the actual text extension and text size. Eg : android:ems Makes the EditText be exactly this many ems wide.
Is there a more appropriate widget?
No.
I don't want to bloat my application.
You won't, unless you put a ton of text in it. While TextView
has a lot of code, your process will already have access to that code, whether you use TextView
or not. The only "bloat" would come from the actual heap space used by the TextView
object itself (and objects that it holds).
For example, let's say I'm building a settings screen, is there a layout I should choose which gives me labels for the properties so I don't have to specify widgets for the labels?
Typically, we would use a PreferenceFragment
, backed by a preference XML resource, instead of having any layout or widgets.
But, if you wanted to roll your own for some reason, use TextView
for the labels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With