2

When setting the background of a TextView with setBackgroundResource, how do you maintain the aspect ratio of the image

view.setBackgroundResource(R.drawable.day_background);

Even though my image is a round circle, it still comes out oval due to the fact that the TextView is landscape.

UPDATE: The issue is that I'm trying to use the background to set an image that I do not want to scale. From what I understand now of the background of a textview you can't do that (it doesn't make sense, its the background of the textview; it has to cover the entire textview).

The answer is to wrap the textview around a a relative view, center it and then add an image view which is also centered behind it. The image view then can be controlled in size and set appropriately.

justdan0227
  • 1,374
  • 18
  • 48

1 Answers1

0

Answered in the UPDATE. Wrap the TextView in a RelativeView and then use an ImageView as the background which can be controlled.

justdan0227
  • 1,374
  • 18
  • 48