tags:

views:

151

answers:

1

i want to draw a graph in a area and i used a linear layout as area.i want to set the size of the graph area,which should be compatible to small,medium ,default emulators etc.i need to set the size for graph area,how can i do it in xml file

for eg in blackberry we use Display.getWidth();Similar is there way to get the width of the display either programmatically or in xml

To expand my area, i did like this, in below image (just added label,which gets an height)

image

To expand it ,i added somemore like this

image1

Regards

Rakesh Shankar.p

A: 

You can't get the width from the xml. You can get it programmatically from your View:

@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {

}

onSizeChanged is called whenever the size of the View changes (including the time the View is first constructed). Alternatively you can use getWidth() inside onDraw:

@Override
public void onDraw(Canvas canvas) {
  int width = this.getWidth();
}
kgiannakakis
is there any way giving width values to the layout,so that it can redraw itself,i just added two links to the post,u just chk that and tell me,what can be donr
Rakesh