如何在android中将图像大小增加到图像视图

时间:2015-12-17 07:30:43

标签: 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();
    }

使用此代码我在Dialog上的Imageview中显示图像我希望在图像视图中显示完整图像,但我无法做到请建议我如何在下面查看以下内容是我的屏幕:

enter image description here

3 个答案:

答案 0 :(得分:3)

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

 android:scaleType="fitXY"

xml中的ImageView

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

答案 1 :(得分:0)

在ImageView中使用此属性。

android:scaleType="fitXY"

答案 2 :(得分:0)

您可以使用fitXY

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

android:scaleType="fitXY"

检查演示 ImageView scaleType Samples

相关问题