图库图像不适合android中的屏幕 [英] Gallery Image not fitting the screen in android

查看:66
本文介绍了图库图像不适合android中的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在图库视图"中显示一堆图像.

I am displaying a bunch of images in the Gallery View.

布局为,

<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>

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

and the custom adapter for loading images,

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;
}

当前我的图片显示为

我的图像适合屏幕的中央部分.但我希望图片能像这张图片一样适合全屏显示

My image is fit to the center part of the screen. but I want the image to fit full screen,like this image

请帮帮我!! 感谢您的帮助!

Please help me out!! Any help is Appreciated!!

推荐答案

问题:

图片适合父对象.但是您的图库参数固定为200.

Image is fitting to the parent.but your gallery params are fixed of 200.

解决方案:

请删除该行.

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

并在xml中进行更改:

and make this change in xml:

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

这篇关于图库图像不适合android中的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆