zoukankan      html  css  js  c++  java
  • 每日总结

    今天学习的是Android的ImageView(图像视图)

    src属性和background属性的区别:

    在API文档中我们发现ImageView有两个可以设置图片的属性,分别是:src和background

    常识:

    ①background通常指的都是背景,而src指的是内容!!

    ②当使用src填入图片时,是按照图片大小直接填充,并不会进行拉伸

    而使用background填入图片,则是会根据ImageView给定的宽度来进行拉伸

    写代码验证区别:

    写个简单的布局测试下:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
        xmlns:tools="http://schemas.android.com/tools"  
        android:id="@+id/LinearLayout1"  
        android:layout_width="match_parent"  
        android:layout_height="match_parent"  
        android:orientation="vertical"  
        tools:context="com.jay.example.imageviewdemo.MainActivity" >  
      
        <ImageView  
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"  
            android:background="@drawable/pen" />  
      
        <ImageView  
            android:layout_width="200dp"  
            android:layout_height="wrap_content"  
            android:background="@drawable/pen" />  
      
        <ImageView  
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"  
            android:src="@drawable/pen" />  
      
        <ImageView  
            android:layout_width="200dp"  
            android:layout_height="wrap_content"  
            android:src="@drawable/pen" />  
      
    </LinearLayout>
    效果图如下:

     宽高都是wrap_content那就一样,是原图大小,但是,当我们固定了宽或者高的话, 差别就显而易见了,blackground完全填充了整个ImageView,而src依旧是那么大, 而且他居中了哦,这就涉及到了ImageView的另一个属性scaleType了! 另外还有一点,这里我们说了只设置width或者height哦!加入我们同时设置了 width和height的话,blackground依旧填充,但是,src的大小可能发生改变哦!

  • 相关阅读:
    nginx重启配置文件nginx.conf不成效
    nginx负载均衡简单配置
    linux下安装nginx
    一台服务器上部署多个tomcat
    tomcat三个端口作用
    tomcat三种部署方式
    查看端口占用, 杀掉
    java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
    火狐浏览器发送post请求
    测试并发报错mysql: too many connections
  • 原文地址:https://www.cnblogs.com/lxywsx/p/14909201.html
Copyright © 2011-2022 走看看