android第五天(ImageView)

1、圖片視圖(ImageView)的基本概念

就是圖片容器;

將圖片放大或縮小至當前ImageView同樣大小,然後將其居中顯示;

將圖片等比例縮放,居中的放到ImageView裏面去;

2、<ImageView/>與ImageView

3、神奇的ScaleType屬性

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ImageView
        android:id="@+id/imageViewId"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#FF0000"
        android:src="@drawable/ab"
        android:scaleType="fitCenter"/>
    <ImageView
        android:id="@+id/imageView2Id"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#00FF00"
        android:src="@drawable/acr"
        android:scaleType="fitStart"/>
</LinearLayout>

展示:

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章