How to display a class which extends view class inside horizontal scroll view...?
<p>I have created bar chart for my application, but my bar chart is not scroll-able, so I have added my liner layout into horizontal scroll view..</p>

<p>Here is my xml file is...</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:id="@+id/horizaontalforscroll"&gt;
&lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/linearforscroll" &gt;
&lt;/LinearLayout&gt;
</code></pre>

<p></p>

<p>Here I'm calling MyGraph class which extends View class..</p>

<pre><code>  LinearLayout linear=(LinearLayout) findViewById(R.id.linearforscroll);
    MyGraph graph = new MyGraph(this);
    linear.addView(graph);
    HorizontalScrollView hr = (HorizontalScrollView)findViewById(R.id.horizaontalforscroll);
    hr.removeAllViewsInLayout();
    hr.addView(linear);
</code></pre>

<p>Add finally my MyGraph class..</p>

<pre><code>      public class MyGraph extends View{

        private static final int SHAPE_WIDTH = 10;
        private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);     
        public MyGraph(Context context) {
            // TODO Auto-generated constructor stub
            super(context);
        }
        @Override
        protected void onDraw(Canvas canvas){
            // TODO Auto-generated method stub
            super.onDraw(canvas);
            paint.setStyle(Style.FILL);
            int legendSize = 0;
            if(legendSize == 0){
                legendSize = height / 5;
            }
            int[] margine = new int[]{40,30,20,200,250};
            int startX = x + margine[0];
            int startY = y;
            int stopX = x + margine[0];
            int stopY = 0;
            Log.d("JWP", "W &amp; H:"+width+":"+height);
            if(width &lt; height){
                stopY = y + height - margine[4];
            }
            else{
                stopY = y + height - margine[3];
            }

            int length = values.length;
            paint.setColor(Color.WHITE);
            canvas.drawLine(startX, startY, stopX, stopY, paint);
            canvas.drawLine(stopX, stopY, x + width, stopY, paint);

            int rHeight = stopY;
            for(int i = 0;i &lt; length; i++){
                double percentage = (values[i]*rHeight)/maxValue;
                Log.d("JWP", "Values:"+values[i]);
                Log.d("JWP", "PERCENTAGE:"+percentage);
                paint.setColor(COLORS[(i) % COLORS.length]);
                int modifiedStratY = rHeight - (int) percentage + 20;
                if(modifiedStratY &gt; rHeight){
                    modifiedStratY = rHeight - (int) percentage;
                }
                canvas.drawRect(startX, modifiedStratY, startX+30, rHeight, paint);
                paint.setTextSize(15);
                canvas.drawText(String.valueOf(values[i]), startX,  modifiedStratY, paint);
                canvas.save();
                canvas.rotate(35, startX, rHeight + 7);
                paint.setColor(Color.WHITE);
                paint.setTextSize(13);
                canvas.drawText(name[i], startX, rHeight + 7, paint);
                canvas.restore();
                startX += 70;
            }

            String xTitle = "Directory Name";
            int xTitleLength = xTitle.length()/2;
            int xTitleStart = (x + width/2) - xTitleLength/2;
            paint.setTextSize(15);
            canvas.drawText(xTitle, xTitleStart,y + rHeight + 65, paint);

            String yTitle = "Amount of Space in MB";
            int yTitleLength = yTitle.length();
            int yTitleStart = (y + rHeight/2) + yTitleLength*2;         
            canvas.save();
            canvas.rotate(-90, x + 10 , yTitleStart);
            canvas.drawText(yTitle, x + 10, yTitleStart, paint);
            canvas.restore();

            paint.setTextSize(12);
            canvas.drawText(String.valueOf(maxValue), x + 12, y + 20, paint);
            canvas.drawText("0.0", x + 11, rHeight, paint);
            float yLabelValue = (float) maxValue / 4;
            int yLabelPoints = rHeight / 4;
            canvas.drawText(String.valueOf(yLabelValue*3), x + 12, (rHeight - yLabelPoints*3 + 20), paint);
            for(int j = 1; j &lt; 3; j++){
                canvas.drawText(String.valueOf(yLabelValue), x + 12, (rHeight - yLabelPoints + 20), paint);
                yLabelPoints += yLabelPoints;
                yLabelValue += yLabelValue;
            }

            int left = x + 15;
            int right = x + width - 5;
            String[] title = new String[length];
            for(int i = 0; i &lt; length; i++){
                title[i] = name[i];
            }
            drawLegends(canvas,title,left,right,y,width,height,legendSize,paint);
        }
}
</code></pre>

<p>My query is, when I run run the code nothing is displayed on screen, if I run without horizontal scroll view result is displayed clearly..
Please help me to solve the issue..</p>

<p>Thank you.</p>
