1.LinearLayout:设置背景时即设置android:background时,假如LayoutLayout设置了android:layout_width="wrap_content"。那么你的布局会和你的图片大小一样大。并不会出现图片失真严重的问题

2.RelativeLayout:设置背景时,即设置了android:background时,假如RelativeLayout设置了android:layout_width="wrap_content"。那么你的布局并不会和你的图片一样大。而是布局填充整个屏幕背景也会跟着填充整个屏幕。这样就造成了图片失真严重。

解决办法:

1.新建一个drawable文件夹,在文件夹中新建一个xml文件,内容如下代码所示:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:andro>
    android:src="@drawable/order_detail_line"
    android:tileMode="disabled" android:gravity="center" >
</bitmap>

2.在你的布局文件中设置RelativeLayout的背景为android:background=“@drawable/xml文件的名称”

3.到此结束,失真问题搞定。

相关文章:

  • 2021-06-07
  • 2022-12-23
  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2021-11-17
  • 2021-06-09
  • 2021-12-13
  • 2022-12-23
相关资源
相似解决方案