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