Prevent background image from stretching the view

后端 未结 6 1373
予麋鹿
予麋鹿 2021-02-18 12:36

Whenever I assign background to a view that is laid out with wrap_content, if the background image is larger than a view, the view is stretched so that it can hold the entire ba

6条回答
  •  死守一世寂寞
    2021-02-18 13:17

    Rather than using a background, you can use a FrameLayout with an ImageView as the first element. Then use android:scaleType="center" so the image won't scale. It will always be it's original size, and centered. Then you can put whatever views you like on top of it in the FrameLayout.

提交回复
热议问题