Ian M
Ian M

Reputation: 607

How to standardise padding and other attributes in dynamically-created TextViews?

My app creates a number of ScrollViews which contain TextView items. The TextView items are created at runtime and are populated from the results of SQL queries. I'd like to standardise the padding (and other attributes such as colour) of these TextViews, without coding separate setPadding statements for each. What's the best way of doing this?

Upvotes: 0

Views: 36

Answers (1)

CodyEngel
CodyEngel

Reputation: 1501

As @Guardanis said, create an XML file containing just the TextView with the desired settings and then use the LayoutInflater to create it. This would probably be your best option since it separates out the presentation layer.

Upvotes: 1

Related Questions