如何增加轮播图像空间?

时间:2012-05-04 13:13:03

标签: android carousel

我在下面的链接carousel demo source code link

中下载了示例android carousel演示源代码

我的疑问是,如果我添加更多图像,图像间隙非常低,那么如何增加图像空间又一次怀疑底部图像反射是隐藏如何获得底部反射图像.....

这是我的xml源:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:pj="http://schemas.android.com/apk/res/com.carouseldemo.main"
    xmlns:bm="com.carouseldemo.main"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <LinearLayout
        android:layout_weight="0.5"
        android:padding="5dip"
        android:gravity="top"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        >
            <com.carouseldemo.controls.Carousel
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/carousel"  
                pj:UseReflection="true"
                pj:Items="@array/entries"
                pj:SelectedItem="0"
                android:animationDuration="200"
            />      
    </LinearLayout>     
</LinearLayout>

请看我的屏幕截图:

enter image description here

3 个答案:

答案 0 :(得分:3)

我修改了Calculate3DPosition中的代码,以便在计算verticalStretchFactor时使用新的y

Calculate3DPosition

 float y = -getHeight()/2f + (float) (diameter/mVerticalStretchFactor * z * android.util.FloatMath.sin(mTheta));

我将这个新属性参数添加到控件的attrs中。我发现140f量级的因素在标准的Droid Phone显示器上运行良好,可以在列表中的项目之间提供更多的垂直间距。我使用控件作为主菜单控件,列表中只有5到6个项目。

答案 1 :(得分:2)

应在 Carousel.java 文件中定义。请检查

中的以下功能
  

的src / COM / carouseldemo /控制/ Carousel.java

getChildStaticTransformation  
makeAndAddView  
setUpChild  
Calculate3DPosition 

答案 2 :(得分:1)

谢谢大家的回答,尤其是Sen,lepert ..我解决了大图像错误选择点击的问题。如果用户只需要触摸图像但问题仍然存在,那么您的解决方案非常有用

如果任何人需要像上面给出的Balaji,使用Sen和lepert解决方案的样本图像那样使旋转器图像不受影响。

如果你想让图像在主要图像上方获得并正确地获得点击/选择,请更改下面给出的代码。这对我有用..

改变

CorousalSpinner.java中的

pointToPosition(int x,int y)无需更改上述解决方案给出的代码

替换

Collections.sort(fitting);

        if(fitting.size() != 0)
            return fitting.get(0).getIndex();
        else
            return mSelectedPosition;

Collections.sort(fitting);

if(fitting.size() != 0){
    if(fitting.size()>1){
        return fitting.get((fitting.size()-1)).getIndex();
    }else{
        return fitting.get(0).getIndex();   
    }


}
else{
    return mSelectedPosition;
}