0

我在图库视图中显示了一堆图像。

布局是,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<Gallery
    android:id="@+id/gallery1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:spacing="10dip" >
</Gallery>

<ImageView
    android:id="@+id/imgfromWebUrl"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</ImageView>
</LinearLayout>

以及用于加载图像的自定义适配器,

public View getView(int arg0, View paramView, ViewGroup arg2) {
    Log.d("","custom Adapter5");
    View localView;
    if (paramView == null) {
        localView = mInflater.inflate(R.layout.property_image_adapter, null);
    } else {
        localView = paramView;
    }       
    ImageView imgfromWebUrl=(ImageView)localView.findViewById(R.id.imgfromWebUrl);          
    Log.d("", "pics[0]: "+pics);
    imgfromWebUrl.setImageBitmap(pics[arg0]);
    imgfromWebUrl.setScaleType(ImageView.ScaleType.FIT_XY);
    imgfromWebUrl.setBackgroundResource(defaultItemBackground);
    imgfromWebUrl.setLayoutParams(new Gallery.LayoutParams(200, 200));
    return imgfromWebUrl;
}

目前我的图像显示为,

在此处输入图像描述

我的图像适合屏幕的中心部分。但我希望图像适合全屏,就像这张图片

在此处输入图像描述

请帮帮我!!任何帮助表示赞赏!

4

3 回答 3

2

将此属性android:scaleType="fitXY" Document 用于 ImageView.ScaleType

于 2013-06-20T05:23:41.380 回答
0

像这样配置布局参数:

i.setLayoutParams( new
Gallery.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT));
于 2014-07-16T06:12:28.887 回答
0

问题:

图像适合父母。但您的画廊参数固定为 200。

解决方案:

请删除该行。

imgfromWebUrl.setLayoutParams(new Gallery.LayoutParams(200, 200));

并在 xml 中进行此更改:

<Gallery
android:id="@+id/gallery1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:spacing="10dip" >

于 2013-06-20T05:26:14.987 回答