新聞中心
Android API中文文檔ImageView是本文要介紹的內(nèi)容,主要是來了解并學習Android API的內(nèi)容,具體Android API的內(nèi)容來看本文詳解。

成都創(chuàng)新互聯(lián)公司制作網(wǎng)站網(wǎng)頁找三站合一網(wǎng)站制作公司,專注于網(wǎng)頁設計,成都網(wǎng)站設計、網(wǎng)站制作,網(wǎng)站設計,企業(yè)網(wǎng)站搭建,網(wǎng)站開發(fā),建網(wǎng)站業(yè)務,680元做網(wǎng)站,已為千余家服務,成都創(chuàng)新互聯(lián)公司網(wǎng)站建設將一如既往的為我們的客戶提供最優(yōu)質(zhì)的網(wǎng)站建設、網(wǎng)絡營銷推廣服務!
一、Android API結(jié)構(gòu)
- java.lang.Object
- android.view.View
- android.widget.ImageView
已知直接子類:
- ImageButton,QuickContactBadge
已知間接子類:
ZoomButton
二、Android API類概述
顯示任意圖像,例如圖標。ImageView類可以加載各種來源的圖片(如資源或圖片庫),需要計算圖像的尺寸,比便它可以在其他布局中使用,并提供例如縮放和著色(渲染)各種顯示選項。
三、Android API中XML屬性
屬性名稱描述
android:adjustViewBounds是否保持寬高比。需要與maxWidth、MaxHeight一起使用,否則單獨使用沒有效果。
android:cropToPadding是否截取指定區(qū)域用空白代替。單獨設置無效果,需要與scrollY一起使用,效果如下,實現(xiàn)代碼見代碼部分:
android:maxHeight設置View的***高度,單獨使用無效,需要與setAdjustViewBounds一起使用。如果想設置圖片固定大小,又想保持圖片寬高比,需要如下設置:
(1)設置setAdjustViewBounds為true;
(2)設置maxWidth、MaxHeight;
(3)設置設置layout_width和layout_height為wrap_content。
android:maxWidth設置View的***寬度。同上。
android:scaleType設置圖片的填充方式。
matrix0用矩陣來繪圖
fitXY1拉伸圖片(不按比例)以填充View的寬高
- layout_
- height
- :30px
- layout_
- width
- :120px
fitStart2按比例拉伸圖片,拉伸后圖片的高度為View的高度,且顯示在View的左邊
fitCenter3按比例拉伸圖片,拉伸后圖片的高度為View的高度,且顯示在View的中間
fitEnd4按比例拉伸圖片,拉伸后圖片的高度為View的高度,且顯示在View的右邊
center5按原圖大小顯示圖片,但圖片寬高大于View的寬高時,截圖圖片中間部分顯示
- layout_
- height
- :60px
- layout_
- width
- :80px
- padding
- :10px
centerCrop6按比例放大原圖直至等于某邊View的寬高顯示。
centerInside7當原圖寬高或等于View的寬高時,按原圖大小居中顯示;反之將原圖縮放至View的寬高居中顯示。
android:src設置View的drawable(如圖片,也可以是顏色,但是需要指定View的大小)
android:tint將圖片渲染成指定的顏色。見下圖:
左邊為原圖,右邊為設置后的效果,見后面代碼。
四、Android API代碼
1、android:tint
- android:layout_width="wrap_content" android:layout_height="wrap_content">
- android:tint="#ffff00" android:src="@drawable/btn_mode_switch_bg"
- android:layout_width="wrap_content" android:layout_height="wrap_content">
2、android:cropToPadding
- android:scrollY="-10px"
- android:cropToPadding="true"
- android:src="@drawable/btn_mode_switch_bg"
- android:layout_width="wrap_content" android:layout_height="wrap_content">
- android:cropToPadding="true" android:src="@drawable/btn_mode_switch_bg"
- android:layout_width="wrap_content" android:layout_height="wrap_content">
- android:scrollY="10px" android:cropToPadding="true" android:src="@drawable/btn_mode_switch_bg"
- android:layout_width="wrap_content" android:layout_height="wrap_content">
- android:scrollY="10px" android:cropToPadding="false" android:src="@drawable/btn_mode_switch_bg"
- android:layout_width="wrap_content" android:layout_height="wrap_content">
小結(jié):
Android API中文文檔ImageView的內(nèi)容介紹完了,希望通過Android API內(nèi)容的學習能對你有所幫助!
分享題目:Android API中文文檔ImageView
網(wǎng)頁URL:http://www.5511xx.com/article/dpijiic.html


咨詢
建站咨詢
