Android 如何使图像适合屏幕?
我有这个xml代码,我想让一个图像适合全屏大小,我有这个代码,但我无法得到我需要的。有人能帮我吗?我是android新手,还有其他可能的方法吗?请帮帮我Android 如何使图像适合屏幕?,android,android-layout,android-xml,Android,Android Layout,Android Xml,我有这个xml代码,我想让一个图像适合全屏大小,我有这个代码,但我无法得到我需要的。有人能帮我吗?我是android新手,还有其他可能的方法吗?请帮帮我 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width=
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:id="@+id/imageView" />
类CustomPagerAdapter扩展了PagerAdapter{
语境;
放平机MLAYOUTIONFLATER;
int[]mResources={
R.drawable.首先,
R.drawable.second,
R.drawable.第三,
R.drawable.第四,
R.drawable.fifth,
第六
};
删除此项:
android:adjustViewBounds="true"
如果您希望ImageView调整其边界以保持其可绘制的纵横比,则使用它。首先,确保您的图像已拉入项目。然后,您希望使用标记设置源图像
android:src="(name of image)"
然后移除
android:adjustViewBounds="true"
这将允许Android将可绘制图像拉伸和倾斜到适当的ImageView大小,而不是在ImageView中保持纵横比。adjustViewBounds if true将调整其边界以保留其可绘制图像的纵横比。 因此,您的图像不会拉伸到适合XY。通过 删除此行 android:adjustViewBounds=“true” 并添加此
android:background=“@drawable/yourImage”我也尝试了不同的scaleType方法,但不起作用,你在哪里设置图片?你忘记了
android:src=“@drawable/your_picture”
使用android:background=“@drawable/pic”
我正在使用viewpager对图像进行幻灯片演示,请指出您从这段代码中得到的不是预期的内容,而不仅仅是您希望得到的内容,因为可能会出现一百万个错误。ImageView ImageView=(ImageView)findViewById(R.id.ImageView);ImageView.setImageResource(mResources[position]);imgview.setScaleType(ScaleType.FIT_XY);
android:adjustViewBounds="true"