zoukankan      html  css  js  c++  java
  • Android关于LinearLayout和RelativeLayout背景设置的区别

    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:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/order_detail_line"
        android:tileMode="disabled" android:gravity="center" >
    </bitmap>

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

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

  • 相关阅读:
    人脸识别-常用的数据库Face Databases From Other Research Groups
    447. Number of Boomerangs
    356. Line Reflection
    149. Max Points on a Line
    279. Perfect Squares
    264. Ugly Number II
    204. Count Primes
    263. Ugly Number
    202. Happy Number
    4. Median of Two Sorted Arrays
  • 原文地址:https://www.cnblogs.com/tony-yang-flutter/p/3338455.html
Copyright © 2011-2022 走看看