title: Changing View Height inside a custom ScrollView onScrollChanged
body: <p>I'm trying to make the following effect:</p>
  
  <p><img src="https://i.stack.imgur.com/RE8du.gif" alt="example"></p>
  
  <p>I have a custom ScrollView (in oder to get the onScrollChanged listener) and a custom View inside it. In the custom View I succeed to place the item as I want.</p>
  
  <p>Here my customView:</p>
  
  <pre><code>public class CustomView extends FrameLayout {
  
  private TextView nameView;
  private TextView emailView;
  private ImageView addressView;
  private Tracks track ;
  private double scrollProgress = 0.0;
  private double topViewScaleFactor = 2.0;
  private double collapsedViewHeight = 200.0;
  private double expandedViewHeight = 700.0; 
  private double scrollProgressPerView = expandedViewHeight;
  
  View v;
  View firstItem;
  View secondView;
  
  
            int itemMinHeight = 200;
            int itemMaxHeight = 700;
  
  public CustomView(MyScrollView paramEventListView, Context paramContext){
  
             super(paramContext);
  }        
  
  
  
  public CustomView(Context context) {
      super(context);
      // TODO Auto-generated constructor stub
  
  }
  
  
  public CustomView(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
      // TODO Auto-generated constructor stub
  
  }
  
  
  public CustomView(Context context, AttributeSet attrs) {
      super(context, attrs);
      // TODO Auto-generated constructor stub
  
  }
  
      @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
      // TODO Auto-generated method stub
      int m = getMeasuredWidth();
  
  
           int itemWidth = (r-l)/getChildCount();
         //  int itemHeight = (b-t)/getChildCount();
  
  
           firstItem = getChildAt(0);
          //firstItem.layout(0, 0, r-l, itemMaxHeight);
           firstItem.measure(View.MeasureSpec.makeMeasureSpec(m, MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(itemMaxHeight, MeasureSpec.EXACTLY));
           firstItem.layout(0, 0, r-l, itemMaxHeight);
  
           secondView = getChildAt(1);
           secondView.measure(View.MeasureSpec.makeMeasureSpec(m, MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(itemMinHeight, MeasureSpec.EXACTLY));
           secondView.layout(0, itemMaxHeight, r-l, itemMinHeight+itemMaxHeight);
  
           int FirstAndSEcondItemHeight = firstItem.getHeight() + secondView.getHeight();
           for(int i=2; i&lt; this.getChildCount(); i++){
                v = getChildAt(i);
            //  v.layout(itemWidth*i, 0, (i+1)*itemWidth, b-t); 
  
               v.layout(0, FirstAndSEcondItemHeight + (itemMinHeight*(i-2)), r-l, FirstAndSEcondItemHeight + ((i-1)*itemMinHeight)); 
           }
  
  
  }
  
  
      @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      // TODO Auto-generated method stub
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  
  
  
      int heightMeasured = 0;
      /*for each child get height and
      heightMeasured += childHeight;*/
       for(int i=0; i&lt; this.getChildCount(); i++){
           heightMeasured += getChildAt(i).getHeight();
       }
  
      //If I am in a scrollview i got heightmeasurespec == 0, so
      if(heightMeasureSpec == 0){
      heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightMeasured, MeasureSpec.EXACTLY);
      }
  
      setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), getDefaultSize(this.getSuggestedMinimumHeight(), heightMeasureSpec));
  }
  </code></pre>
  
  <p>Here my Custom ScrollView:</p>
  
  <pre><code>public class MyScrollView extends ScrollView{
  
  
  
  public MyScrollView(Context context) {
      super(context);
  
  }
  
  public MyScrollView(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
      add(context);
  } 
  
  public MyScrollView(Context context, AttributeSet attrs) {
      super(context, attrs);
  }
  
  public void setScrollViewListener(ScrollViewListener scrollViewListener) {
      this.scrollViewListener = scrollViewListener;
  
  
  }
  @Override
  protected void onScrollChanged(int x, int y, int oldx, int oldy) {
      super.onScrollChanged(x, y, oldx, oldy);
  
   // How can I acces to each child in the customView class, and change their height depending on the scrollChanged
  
  
  }
  </code></pre>
  
  <p>But now I need to change the item height when I scroll the scrollview. I don't know what to put in the onScrollChanged...
  If someone has an idea?</p>
  
  <p>Thanks</p>