@@ -713,6 +713,18 @@ private BackgroundDrawParams getDrawParams(float width, float height) {
713713 res .posX = spaceX ;
714714 }
715715
716+ if ("center" .equals (vy .getString ().toLowerCase (Locale .ENGLISH ))) {
717+ res .posY = spaceY / 2 ;
718+ } else if ("bottom" .equals (vy .getString ().toLowerCase (Locale .ENGLISH ))) {
719+ res .posY = spaceY ;
720+ }
721+ } else if ("number" .equals (vx .getType ()) && "ident" .equals (vy .getType ())) {
722+ if ("%" .equals (vx .getUnit ())) {
723+ res .posX = spaceX * vx .getValue () / 100 ;
724+ } else if ("number" .equals (vx .getType ()) || "px" .equals (vx .getUnit ()) || vx .getUnit () == null || vx .getUnit ().isEmpty ()) {
725+ res .posX = vx .getValue ();
726+ }
727+
716728 if ("center" .equals (vy .getString ().toLowerCase (Locale .ENGLISH ))) {
717729 res .posY = spaceY / 2 ;
718730 } else if ("bottom" .equals (vy .getString ().toLowerCase (Locale .ENGLISH ))) {
@@ -731,17 +743,22 @@ private static CSSValue[] parsePosition(CSSValue[] values) {
731743 }
732744
733745 CSSValue [] result = null ;
734- if (values .length == 1 && "ident" . equals ( values [ 0 ]. getType ()) ) {
735- String val = values [ 0 ]. getString (). toLowerCase ( Locale . ENGLISH );
746+ if (values .length == 1 ) {
747+ // If you only one keyword is specified, the other value is "center"
736748 CSSValue center = new CSSValue ("ident" , "center" , null , 0 );
737749
738- // If you only one keyword is specified, the other value is "center"
739- if ("left" .equals (val ) || "right" .equals (val )) {
750+ if ("ident" .equals (values [0 ].getType ())) {
751+ String val = values [0 ].getString ().toLowerCase (Locale .ENGLISH );
752+
753+ if ("left" .equals (val ) || "right" .equals (val )) {
754+ result = new CSSValue []{values [0 ], center };
755+ } else if ("top" .equals (val ) || "bottom" .equals (val )) {
756+ result = new CSSValue []{center , values [0 ]};
757+ } else if ("center" .equals (val )) {
758+ result = new CSSValue []{center , center };
759+ }
760+ } else if ("number" .equals (values [0 ].getType ())) {
740761 result = new CSSValue []{values [0 ], center };
741- } else if ("top" .equals (val ) || "bottom" .equals (val )) {
742- result = new CSSValue []{center , values [0 ]};
743- } else if ("center" .equals (val )) {
744- result = new CSSValue []{center , center };
745762 }
746763 }
747764
0 commit comments