How to draw a dynamic drawing over a layout
<p>I am trying to make a thermometer. For this I have an image of a thermometer(a png file) which i have inserted
into the layout using ImageView. Now I want to draw a line over this image to show the effect of temperature reading.</p>

<p>Here is my code.</p>

<p>main.xml</p>

<p></p>

<pre><code>&lt;AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    &gt;
&lt;ImageView 
&lt;/ImageView&gt;
&lt;com.focusone.Android.DrawExample.CustomDrawableView    
    android:id="@+id/custom_drawable_view"   
     android:layout_width="fill_parent"          
    android:layout_height="wrap_content" 
    height='100'
    /&gt; 
&lt;/AbsoluteLayout&gt;
</code></pre>

<p>DrawExample.java</p>

<pre><code>package com.focusone.Android.DrawExample;

public class DrawExample extends Activity {
    /** Called when the activity is first created. */

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }

}
</code></pre>

<p>CustomDrawableView.java</p>

<pre><code>public class CustomDrawableView extends View {
    private ShapeDrawable mDrawable;

    public CustomDrawableView(Context v,AttributeSet as){ 
        super(v,as); 
        drawShape(as); 
    } 
    public void drawShape(AttributeSet ast) {

        int x =45; int y=15 ; int width=5; int height=0 ;
                    height= Integer.parseInt(ast.getAttributeValue(null, "height"));   
                    mDrawable = new ShapeDrawable(new RectShape());   
                    mDrawable.getPaint().setColor(0xff74AC23);   
                    mDrawable.setBounds(x, y, x + width, y + height); 
    }
   protected void onDraw(Canvas canvas) {
        mDrawable.draw(canvas);
    }
}
</code></pre>

<p>Now I can draw a line on top of the thermometer image using this program.</p>

<p>But how do i change the height of line during runtime.
Since height=100 is written in the xml file I don't know how I can change it.</p>

<p>Please somebody help me.</p>
