public String generateXml(Screen screen){
  Resource resource=new Resource();
  List<Dimen> dimens=resource.getDimens();
  float cellWidth=screen.getWidth() * 1.0f / baseWidth;
  float cellHeight=screen.getHeight() * 1.0f / beseHeight;
  String result=null;
  Dimen dimen=null;
  for (int i=1; i <= baseWidth; i++) {
    result=DECIMAL_FORMAT.format(i * cellWidth);
    dimen=new Dimen();
    dimen.setName(String.format("x%d",i));
    dimen.setValue(String.format("%spx",result));
    dimens.add(dimen);
  }
  for (int i=1; i <= beseHeight; i++) {
    result=DECIMAL_FORMAT.format(i * cellHeight);
    dimen=new Dimen();
    dimen.setName(String.format("y%d",i));
    dimen.setValue(String.format("%spx",result));
    dimens.add(dimen);
  }
  String xml=XSTREAM.toXML(resource);
  return xml;
}

public String generateXml ( Screen screen ) { Resource resource = new Resource ( ) ; List < Dimen > dimens = resource . getDimens ( ) ; float cellWidth = screen . getWidth ( ) * 1.0f / baseWidth ; float cellHeight = screen . getHeight ( ) * 1.0f / beseHeight ; String result = null ; Dimen dimen = null ; for ( int i = 1 ; i <= baseWidth ; i ++ ) { result = DECIMAL_FORMAT . format ( i * cellWidth ) ; dimen = new Dimen ( ) ; dimen . setName ( String . format ( "x%d" , i ) ) ; dimen . setValue ( String . format ( "%spx" , result ) ) ; dimens . add ( dimen ) ; } for ( int i = 1 ; i <= beseHeight ; i ++ ) { result = DECIMAL_FORMAT . format ( i * cellHeight ) ; dimen = new Dimen ( ) ; dimen . setName ( String . format ( "y%d" , i ) ) ; dimen . setValue ( String . format ( "%spx" , result ) ) ; dimens . add ( dimen ) ; } String xml = XSTREAM . toXML ( resource ) ; return xml ; }
using w and h to generate xml
