【问题标题】:increase images sizes loads in carousel view android在轮播视图android中增加图像大小加载
【发布时间】:2013-07-24 14:56:25
【问题描述】:

我创建了应用程序以在轮播视图中显示来自互联网的图像。我使用 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 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>

【问题讨论】:

    标签: android image carousel


    【解决方案1】:

    我认为你应该在水平滚动视图中使用水平方向的线性布局,然后你应该在这个线性布局中添加具有 FillParent 高度和宽度的 ImageView。

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

    【讨论】:

    • 谢谢suresh。我听从了你的回答。但我遇到了运行时错误。我编辑了我的问题。在那里你可以看到我如何将图像视图添加到轮播视图中。那你看看能不能给我答案...
    • 这项工作。但我不想使用滚动视图。相反,我想将完整图像加载到我的屏幕中而不进行裁剪。
    • 什么是运行时错误。你能贴这个吗?为了回答您的代码,我需要检查您的整个 XML 文件和 Horizo​​ntalCarouselLayout 的定义。
    • ok..现在不会出现运行时错误。这是我的错误。我在我的问题中给出了 imageview xml 布局的完整代码。我不想使用滚动视图。而不是我想在我的轮播视图中加载完整图像而不进行裁剪。另外我想增加图像宽度在轮播视图中加载的图像..
    • 为什么要设置 android:layout_width="600dp" android:layout_height="500dp"
    猜你喜欢
    • 1970-01-01
    • 2016-10-13
    • 2012-09-28
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    • 1970-01-01
    • 2015-03-22
    • 1970-01-01
    相关资源
    最近更新 更多