2012-06-19 65 views
0

我新來的Android開發機器人的CoverFlow高度

我米目前正在測試機器人的CoverFlow這裏找到:http://code.google.com/p/android-coverflow/

我succeffully實現了它在我的項目,但我不能找到一種方法來給插件的所需的寬度和高度

我的佈局:

<view 
    xmlns:coverflow="http://schemas.android.com/apk/res/com.accessdev.myapp" 
    android:id="@+id/coverflow" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginTop="5dip" 
    class="pl.polidea.coverflow.CoverFlow" 
    coverflow:imageHeight="150dip" 
    coverflow:imageWidth="100dip" > 
</view> 

改變的CoverFlow:imageHeight和的CoverFlow:imageWidth只有AFF影響圖像的大小,但小部件並沒有填充佈局的高度(它就像屏幕的10%,我沒有設法改變它呢)

+0

嘿如果你已經得到了解決,請分享,因爲我不能這樣做。 – 2015-04-08 10:23:14

回答

1

正如你可以在類中看到的方法setAdapter中的Coverflow,適配器寬度並將高度設置爲imageWidth/imageHeight,因此請修改parseAttributes方法中兩個變量的值。

編輯:我想你可以修改AbstractCoverflowAdapter來擴充一個xml,其中包含一個ImageView,寬度/高度設置爲fill_parent。這應該工作:d

對於XML:

<?xml version="1.0" encoding="utf-8"?> 
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/image" 
    android:layout_width="200dip" 
    android:layout_height="400dip" 
    android:src="@drawable/ic_launcher" /> 

在適配器的getView():

 LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     row = inflater.inflate(R.layout.your_layout, parent, false); 
     ImageView image = (ImageView) row.findViewById(R.id.image); 
     image.setImageBitmap(your_bitmap); 
+0

如果我在parseAttributes方法中像這樣硬編碼:imageWidth = 480; imageHeight = 320;我得到同樣的問題 –

+0

如果你看看AbstractCoverFlowAdapter,你可以在getView中看到這個:imageView.setLayoutParams(new CoverFlow.LayoutParams((int)width,(int)height)); - 這意味着coverflow中的圖像將獲得parseAttributtes()中給出的尺寸。在我看來,封面流只會採用在那裏給出的尺寸,除非有辦法將代碼/佈局修改爲另一種方式。 –