首页 > 其他 > 详细

Anfroid 在界面中显示图片 ImageView

时间:2016-04-16 21:29:46      阅读:387      评论:0      收藏:0      [点我收藏+]

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

技术分享

效果:

技术分享

Anfroid 在界面中显示图片 ImageView

原文:http://www.cnblogs.com/moonlightpoet/p/5399226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!