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图片:

    效果:

  • 相关阅读:
    AI
    CentoOS6.6安装netcat
    ip防刷脚本
    php git pull
    冥想_ PHP抽奖程序概率算法
    如何在CentOS配置Apache的HTTPS服务
    C++ 用RGB 三种颜色绘图
    Linux Vsftpd 连接超时解决方法(被动模式)
    js 函数返回函数
    模拟jquery的$()选择器的实现
  • 原文地址:https://www.cnblogs.com/moonlightpoet/p/5399226.html
Copyright © 2011-2022 走看看