title: MP Chart in listView
body: <p>Please assist me with implementing MP Line Chart in ListView; it works good in recycler view, however it loses its size as I add more than 5 items.
  Because of the scroll view, I'm using an expanded listView to reduce issues, yet the chart looks like this.</p>
  <pre><code>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_margin=&quot;10sp&quot;
      android:orientation=&quot;vertical&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;TextView
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:textSize=&quot;20sp&quot;
          android:textStyle=&quot;bold&quot;
          android:textColor=&quot;@color/black&quot;
          android:text=&quot;@string/most_active_stocks&quot;/&gt;
  
  
      &lt;LinearLayout
          android:visibility=&quot;visible&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;horizontal&quot;
          android:layout_gravity=&quot;center&quot;
          android:gravity=&quot;center&quot;
          android:layout_margin=&quot;10sp&quot;&gt;
  
  
  
          &lt;Button
              android:layout_width=&quot;wrap_content&quot;
              android:textSize=&quot;10sp&quot;
              android:layout_gravity=&quot;center&quot;
              android:layout_height=&quot;40dp&quot;
              android:layout_margin=&quot;5dp&quot;
              android:background=&quot;@drawable/virtualtrading_button&quot;
              android:text=&quot;Volume&quot;
              android:gravity=&quot;center&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
          &lt;Button
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;40dp&quot;
              android:textSize=&quot;10sp&quot;
              android:layout_gravity=&quot;center&quot;
              android:layout_margin=&quot;5dp&quot;
              android:background=&quot;@drawable/virtualtrading_button&quot;
              android:text=&quot;%Turnover&quot;
              android:gravity=&quot;center&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
  
          &lt;Button
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;40dp&quot;
              android:textSize=&quot;10sp&quot;
              android:layout_margin=&quot;5dp&quot;
              android:layout_gravity=&quot;center&quot;
              android:background=&quot;@drawable/virtualtrading_button&quot;
              android:text=&quot;Range&quot;
              android:gravity=&quot;center&quot;
              android:textColor=&quot;@color/black&quot; /&gt;
      &lt;/LinearLayout&gt;
  
  
  
  
      &lt;RelativeLayout
  
          android:layout_width=&quot;fill_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;vertical&quot;&gt;
  
  
          &lt;com.catalyst.maksl.Components.ExpandableHeightListView
  
              android:id=&quot;@+id/moverlist&quot;
              android:layout_width=&quot;fill_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_gravity=&quot;center_horizontal&quot;
              android:drawSelectorOnTop=&quot;false&quot;
              android:fadingEdge=&quot;vertical&quot;
              android:divider=&quot;@android:color/transparent&quot;
              android:dividerHeight=&quot;5dp&quot;
              android:fitsSystemWindows=&quot;true&quot;
              android:listSelector=&quot;#00000000&quot;
              android:scrollbars=&quot;none&quot;
              android:smoothScrollbar=&quot;true&quot; /&gt;
  
  
      &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>ExpandableListView Class</p>
  <pre><code>public class ExpandableHeightListView extends ListView {
  
  boolean expanded = false;
  
  public ExpandableHeightListView(Context context)
  {
      super(context);
  }
  
  public ExpandableHeightListView(Context context, AttributeSet attrs)
  {
      super(context, attrs);
  }
  
  public ExpandableHeightListView(Context context, AttributeSet attrs,int defStyle)
  {
      super(context, attrs, defStyle);
  }
  
  public boolean isExpanded()
  {
      return expanded;
  }
  
  @Override
  public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
  {
      // HACK! TAKE THAT ANDROID!
      if (isExpanded())
      {
          // Calculate entire height by providing a very large height hint.
          // But do not use the highest 2 bits of this integer; those are
          // reserved for the MeasureSpec mode.
          int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE &gt;&gt; 2, MeasureSpec.AT_MOST);
          super.onMeasure(widthMeasureSpec, expandSpec);
  
          ViewGroup.LayoutParams params = getLayoutParams();
          params.height = getMeasuredHeight();
      }
      else
      {
          super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      }
  }
  
  public void setExpanded(boolean expanded)
  {
      this.expanded = expanded;
  }
  </code></pre>
  <p>}</p>
  <p>adapter class :</p>
  <pre><code>public class MostActiveStocksAdapter extends BaseAdapter {
  
  private static LineDataSet set1;
  public static Drawable drawablePositive = ContextCompat.getDrawable(Logs.globalContext, R.drawable.graph_green_bg);
  public static Drawable drawable_negative = ContextCompat.getDrawable(Logs.globalContext, R.drawable.graph_bg);
  Context context;
  private Double changePercentage;
  ArrayList&lt;String&gt; arrayList = new ArrayList&lt;String&gt;();
  LayoutInflater mInflater = null;
  private ViewHolder holder;
  public ArrayList&lt;Entry&gt; values;
  public LineData data;
  
  
  
  
  
  
  public MostActiveStocksAdapter(Context context, ArrayList&lt;String&gt; arrayList) {
  
      this.context = context;
      this.arrayList = arrayList;
      mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
  
  }
  
  
  @Override
  public int getCount() {
      return arrayList.size();
  }
  
  @Override
  public Object getItem(int position) {
      return arrayList.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
          convertView = mInflater.inflate(R.layout.most_active_stocks_listitem, null);
          holder = new ViewHolder();
          holder.moverSymbolName = (TextView) convertView.findViewById(R.id.moversymbolName);
          holder.moverScripName = (AutoResizeTextView) convertView.findViewById(R.id.moversmainSymbolName);
          holder.moverLastTradePrice = (TextView) convertView.findViewById(R.id.moverslastTradePrice);
          holder.moverchange = (AutoResizeTextView) convertView.findViewById(R.id.moversindexChange);
          holder.moverMarket = (TextView) convertView.findViewById(R.id.moverssymbolMarket);
          holder.sector = convertView.findViewById(R.id.movertextSector);
          holder.nameIcon = convertView.findViewById(R.id.moverNameicon);
          holder.masLineChart = convertView.findViewById(R.id.moversgraph);
  
          convertView.setTag(holder);
      } else {
          holder = (ViewHolder) convertView.getTag();
      }
  
      ScripBean scripBean = Logs.allScripBean.get(arrayList.get(position));
      MostActiveStockMarketFeedBean marketFeedBean = Logs.mostActiveStockMarketFeedBeanHashMap.get(arrayList.get(position));
  
  
      if (marketFeedBean != null) {
  
          changePercentage = marketFeedBean.getChange() / (marketFeedBean.getLastTradePrice() - marketFeedBean.getChange()) * 100;
  
          holder.moverScripName.setText(marketFeedBean.getScrip());
          holder.moverSymbolName.setText(marketFeedBean.getScripName());
          holder.sector.setText(scripBean.getSectorName());
          holder.nameIcon.setText(marketFeedBean.getScrip().substring(0,1));
          holder.moverLastTradePrice.setText(Logs.priceFormat.format(marketFeedBean.getLastTradePrice()).replace(&quot;-&quot;, &quot;&quot;));
  
          setData(5,3);
          customiseChart();
  
          if(marketFeedBean.getChange() != 0.0) {
  
  
              if (Logs.priceFormat.format(changePercentage).contains(&quot;-&quot;)) {
  
                  holder.moverLastTradePrice.setBackground(context.getResources().getDrawable(R.drawable.bg_negativecell));
  
  
              }
              else
              {
  
                  holder.moverLastTradePrice.setBackground(context.getResources().getDrawable(R.drawable.bg_positivecell));
  
  
  
              }
              holder.moverchange.setText(marketFeedBean.getChange() + &quot; &quot; + &quot;(&quot; + Logs.priceFormat.format(changePercentage).replace(&quot;-&quot;, &quot;&quot;) + &quot;%)&quot;);
          }
  
          else
          {
              holder.moverchange.setText(&quot;(0.00%)&quot;);
  
          }
  
      }
  
      else {
  
          String sm = arrayList.get(position);
          holder.moverScripName.setText(sm.split(&quot;\\:&quot;, -1)[0]);
          holder.moverMarket.setText(sm.split(&quot;\\:&quot;, -1)[1]);
          holder.moverSymbolName.setText(&quot;&quot;);
          holder.moverLastTradePrice.setText(&quot;0.00&quot;);
          holder.moverchange.setText(&quot;0.00&quot;);
  
      }
      return convertView;
  }
  
  private void setData(int count, float range) {
  
  
      values = new ArrayList&lt;&gt;();
  
      for (int i = 0; i &lt; count; i++) {
  
          float val = (float) (Math.random() * range) - 30;
          values.add(new Entry(i, val));
      }
  
  
      set1 = new LineDataSet(values, &quot;DataSet 1&quot;);
      set1.setDrawCircles(false);
      set1.setDrawFilled(true);
      set1.setLineWidth(1f);
      set1.setColor(Color.GREEN);
      set1.setMode(LineDataSet.Mode.CUBIC_BEZIER);
      set1.setDrawFilled(true);
      set1.setFillDrawable(drawablePositive);
      set1.setFillFormatter(new IFillFormatter() {
          @Override
          public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
              return holder.masLineChart.getAxisLeft().getAxisMinimum();
  
          }
      });
      ArrayList&lt;ILineDataSet&gt; dataSets = new ArrayList&lt;&gt;();
      dataSets.add(set1);
      data = new LineData(dataSets);
  
      holder.masLineChart.setData(data);
  
  
  }
  
  private void customiseChart()
  {
  
      holder.masLineChart.getDescription().setEnabled(false);
      holder.masLineChart.setDrawGridBackground(false);
      holder.masLineChart.setDragEnabled(false);
      holder.masLineChart.getLegend().setEnabled(false);
      holder.masLineChart.setScaleEnabled(true);
      holder.masLineChart.setScaleYEnabled(false);
      holder.masLineChart.setScaleXEnabled(true);
      holder.masLineChart.setDrawGridBackground(false);
      holder.masLineChart.getXAxis().setEnabled(false);
      holder.masLineChart.getLineData().setDrawValues(false);
      holder.masLineChart.getXAxis().setDrawGridLines(false);
      holder.masLineChart.getXAxis().setDrawAxisLine(false);
      holder.masLineChart.getAxisLeft().setDrawGridLines(false);
      holder.masLineChart.getAxisRight().setDrawGridLines(false);
      holder.masLineChart.getAxisRight().setDrawZeroLine(true);
      holder.masLineChart.getAxisLeft().setDrawZeroLine(true);
      holder.masLineChart.getAxisRight().setDrawLabels(false);
      holder.masLineChart.getAxisLeft().setDrawLabels(false);
      holder.masLineChart.getAxisLeft().setEnabled(false);
      holder.masLineChart.getAxisRight().setEnabled(true);
      holder.masLineChart.getAxisRight().setZeroLineColor(Color.BLACK);
      holder.masLineChart.getAxisRight().setAxisLineColor(Color.BLACK);
      holder.masLineChart.setMaxHighlightDistance(150);
      holder.masLineChart.setViewPortOffsets(0, 0, 0, 0);
      holder.masLineChart.setTouchEnabled(false);
      holder.masLineChart.setPinchZoom(false);
  }
  
  private class ViewHolder {
      TextView moverSymbolName;
      TextView moverMarket;
      AutoResizeTextView moverScripName;
      TextView moverLastTradePrice;
      AutoResizeTextView moverchange;
      TextView sector;
      TextView nameIcon;
      LineChart masLineChart;
  
  }
  </code></pre>
  <p>P.S: this ListView is in fragment.</p>
  <p><a href="https://i.stack.imgur.com/ogeBk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ogeBk.jpg" alt="enter image description here" /></a></p>