Hello All,

I have a custom view
.........

package com.yasir.canvasTest;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.util.Log;
import android.view.View;


public class GraphView extends View {

    private static final String TAG = "GraphView";
    public static boolean BAR = true;
    public static boolean LINE = false;

    private Paint paint;
    private float[] values;
    private String[] horlabels;
    private String[] verlabels;
    private String title;
    private boolean type;
    public Canvas tmpCanvas = null;

    public GraphView(Context context, float[] values, String title, String[]
horlabels, String[] verlabels) {
        super(context);
        //setScrollContainer(true);
        Log.v(TAG,"On GraphView==>");




        paint = new Paint();

        setWillNotDraw(false);
        requestLayout();
        invalidate();
    }

    @Override
    protected void onDraw(Canvas canvas) {




        Log.v(TAG,"<==On Draw");

/// drawing code here
        invalidate();
    }

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        Log.v(TAG,"On onMeasure==>");
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
        int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
        setMeasuredDimension(
                parentWidth * 2, parentHeight);
    }

}
...............
Activity: onCreate
...............
    setContentView(R.layout.horscroll);



        HorizontalScrollView hsView = (HorizontalScrollView)
findViewById(R.id.hzsv);

        LinearLayout ll = (LinearLayout) findViewById(R.id.linearParent);
        ll.removeAllViews();


        // create custom view and add to laywout
        GraphView graphView = new GraphView(this, values,
"GraphViewDemo",horlabels, verlabels, GraphView.LINE);


        hsView.requestLayout();
        hsView.setWillNotDraw(false);

        ll.requestLayout();
        ll.setWillNotDraw(false);
        ll.addView(graphView);

.....................
Xml
....................
<?xml version="1.0" encoding="utf-8"?>

<HorizontalScrollView
 android:id="@+id/hzsv"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 xmlns:android="http://schemas.android.com/apk/res/android";>
<LinearLayout android:id="@+id/linearParent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></LinearLayout>
 </HorizontalScrollView>
..................


Regards,
Yasir Perwez

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to