Android ImageView 的默认 ScaleType 是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2951923/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the default ScaleType of ImageView?
提问by user256239
What's the default ScaleType of ImageView?If I put an image which is 400 pixels x 400 pixels on a normal screen (320x480) without specifying ScaleType, how will the image be scaled?
ImageView的默认ScaleType是什么?如果我在普通屏幕(320x480)上放置一个400像素x 400像素的图像而不指定ScaleType,图像将如何缩放?
Thanks.
谢谢。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/big_image"
/>
</RelativeLayout>
回答by Robby Pond
ImageView.ScaleType
FIT_CENTER
Scale the image using
CENTER
. From XML, use this syntax:android:scaleType="fitCenter"
.
ImageView.ScaleType
FIT_CENTER
使用 缩放图像
CENTER
。在 XML 中,使用以下语法:android:scaleType="fitCenter"
.