zoukankan      html  css  js  c++  java
  • Anfroid 在界面中显示图片 ImageView

    ImageView
    1.什么是ImageView
    是显示图片的一个控件
    2.ImageView属性
    android:src ImageView的内容颜色 
    android:background ImageView背景图片
    android:color ImageView的RGB颜色


    项目里我新建了一个Icon,名为ic_lena。
    这个项目用于演示ImageView的src属性和bakground的区别。
    src和background属性可以同时存在。

    ImageView部分的代码片段:

    <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_lena" 
            android:background="#00FFFF"
            />
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:orientation="vertical"
        >
    
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_lena" 
            android:background="#00FFFF"
            />
        
        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/ic_lena" />
        
        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="#00FFFF" />
    
        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:background="@drawable/ic_lena" />
        
    </LinearLayout>
    fragment_main.xml

    不同分辨率下图片的显示:

    ic_lena图片:

    效果:

  • 相关阅读:
    函数参数太多的一种简化方法
    laravel 获取所有表名
    使用 laravel 的 queue 必须知道的一些事
    git "refusing to merge unrelated histories" 解决方法
    使用 xhprof 进行 php 的性能分析
    php 性能优化
    js原生实现轮播图效果(面向对象编程)
    nextSibling 和nextElementSibling
    如何在页面中使用svg图标
    svg动画 animate
  • 原文地址:https://www.cnblogs.com/moonlightpoet/p/5399226.html
Copyright © 2011-2022 走看看