繁体   English   中英

在轮播视图中增加图像大小的负载

[英]increase images sizes loads in carousel view android

我创建了一个应用,以在轮播视图中显示来自互联网的图像。 我使用imageview将图像加载到轮播视图中。 就像下面的方法一样。

public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.showsmain, null);

        ImageView image=(ImageView)vi.findViewById(R.id.imageView1);
       // RelativeLayout rlayout=(RelativeLayout)vi.findViewById(R.id.rlayouts);
       image.setImageResource(R.drawable.black);
        orgWidth = image.getDrawable().getIntrinsicWidth();
        orgHeight = image.getDrawable().getIntrinsicHeight();
        imageLoader.DisplayImage(data[position], image);
        imageLoader.getDimension(widthScreen, heightScreen);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                widthScreen, heightScreen/3);
        params.width=widthScreen;
            image.setLayoutParams(params);
            image.setScaleType(ImageView.ScaleType.FIT_XY);
            //rlayout.addView(image);
        return vi;
    }

我的轮播布局xml文件是,

<com.touchmenotapps.carousel.simple.HorizontalCarouselLayout
        android:id="@+id/carousel_layout_event"
        android:layout_width="600dp"
        android:layout_height="500dp"
        android:layout_above="@+id/relativeLayout1"
        android:layout_alignTop="@+id/carousel_layout" >

    </com.touchmenotapps.carousel.simple.HorizontalCarouselLayout>

然后在轮播中以如下方式显示图片,

![在此处输入图片描述] [1]

在这里我想增加图像的宽度和高度。 这意味着一张图像必须在屏幕上加载

 public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.showimage, null);
        ImageView image=(ImageView)vi.findViewById(R.id.imageView1);
        //LinearLayout rlayout=(LinearLayout)vi.findViewById(R.id.layout);
       image.setImageResource(R.drawable.black);
        orgWidth = image.getDrawable().getIntrinsicWidth();
        orgHeight = image.getDrawable().getIntrinsicHeight();
        imageLoader.DisplayImage(data[position], image);
        imageLoader.getDimension(widthScreen, heightScreen);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                widthScreen,heightScreen/3);
        params.width=widthScreen/2;
            image.setLayoutParams(params);
            image.setScaleType(ImageView.ScaleType.FIT_XY);
            //rlayout.addView(image);
        return vi;
    }

这样,我将imageview添加到轮播视图中。

怎么做。 我问了一个类似这个问题。 但是我没有得到答案。 请帮助我。 请.....

我的imageview xml布局文件。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:id="@+id/rlayouts">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:scaleType="fitXY"
        android:layout_alignParentTop="true" />

</RelativeLayout>

我认为您应该在水平ScrollView中使用面向水平的线性布局,然后在此线性布局中添加具有FillParent Height和Width的ImageView。

如果再详细说明您的问题,那就太好了。

暂无
暂无

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

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