how to increase carousel image space?

前端 未结 3 952
独厮守ぢ
独厮守ぢ 2021-01-03 13:29

I downloaded sample android carousel demo source code in below link carousel demo source code link

my doubt is if I add more images, images gap is very low so how to

相关标签:
3条回答
  • 2021-01-03 14:20

    I modified the code in Calculate3DPosition to include the usage of a NEW verticalStretchFactor in the calculation of the y:

    Calculate3DPosition

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

    I added this new attribute parameter to the attrs of the control. I found a factor on the order of 140f worked well on a standard Droid Phone display to provide more vertical spacing between the items in the list. I was using the control as a Home Menu control and only had 5 to 6 items in the list.

    0 讨论(0)
  • 2021-01-03 14:23

    It should be defined in Carousel.java file. Please check the following functions in

    src/com/carouseldemo/controls/Carousel.java

    getChildStaticTransformation  
    makeAndAddView  
    setUpChild  
    Calculate3DPosition 
    
    0 讨论(0)
  • 2021-01-03 14:27

    Thank you all for your answers, especially Sen ,lepert.. I fix the issue of false selection of click with large images .Your solution is very much useful if the user needs to get the images untouched only but the issue still remains .

    If any one need to make the spinner images untouched as given like the sample image given above by Balaji ,Use Sen's and lepert solution.

    And if you want to make the images beneth the main one and get clicks /selections correctly change the code as given below ..This works for me ..

    Change in

    pointToPosition(int x, int y) in CorousalSpinner.java no need to change the code given by the above solutions

    replace

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

    with

    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;
    }
    
    0 讨论(0)
提交回复
热议问题