繁体   English   中英

如何在android中的图像视图中增加完整的图像大小

[英]how to increase image Size full to Image view in android

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="250dp"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="50dp"
    android:layout_marginRight="50dp"
    android:layout_marginTop="10dp"
        >    
    <ImageView
        android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"    
        />  

</RelativeLayout>

图片提醒:

 public void imagealert(int position) {
        final Dialog dialog = new Dialog(mcontext);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.getWindow()
                .setSoftInputMode(
                        WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
                                | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        dialog.setContentView(R.layout.imagepopulayout);
        ImageView image = (ImageView) dialog.findViewById(R.id.image);
        String imgae = dbManager.GetimageUrl(datamodel.get(position).getProdcutid());
        String imageUrl = "http://bhaskarmart.com/Images/" + imgae;
        Picasso.with(mcontext).load(imageUrl).into(image);
        dialog.show();
    }

使用此代码我在对话框的Imageview中显示图像,我想在Image视图中显示完整的图像,但我无法执行,请建议我如何在下面显示此屏幕:

在此处输入图片说明

要使用“整个图像”视图占据图像,您需要为“图像”视图添加另一个属性:

 android:scaleType="fitXY"

您在XML中的ImageView

    <ImageView
    android:id="@+id/image"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitXY" />

在ImageView中使用此属性。

android:scaleType="fitXY"

您可以使用fitXY

缩放x和y尺寸以完全匹配视图大小; 不保持图像的宽高比。

android:scaleType="fitXY"

查看演示ImageView scaleType示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM