开发者

How to draw the graph in android based on its height and size

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 Shanka开发者_如何转开发r.p


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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜