Merge "Some code refactoring"
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index ecbd997..5a5fae4 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6586,11 +6586,11 @@
                     scrollx = left;
                 }
             }
-        } else if (a == Layout.Alignment.ALIGN_LEFT) {
-            scrollx = (int) FloatMath.floor(mLayout.getLineLeft(line));
-        } else { // a == Layout.Alignment.ALIGN_RIGHT
+        } else if (a == Layout.Alignment.ALIGN_RIGHT) {
             int right = (int) FloatMath.ceil(mLayout.getLineRight(line));
             scrollx = right - hspace;
+        } else { // a == Layout.Alignment.ALIGN_LEFT (will also be the default)
+            scrollx = (int) FloatMath.floor(mLayout.getLineLeft(line));
         }
 
         if (ht < vspace) {
diff --git a/tests/BiDiTests/res/layout/basic.xml b/tests/BiDiTests/res/layout/basic.xml
index d438b2c..c1ebd20 100644
--- a/tests/BiDiTests/res/layout/basic.xml
+++ b/tests/BiDiTests/res/layout/basic.xml
@@ -40,7 +40,7 @@
                       android:textSize="32dip"
                       android:text="@string/textview_text"
                     />
-    
+
             <EditText android:id="@+id/edittext"
                       android:layout_height="wrap_content"
                       android:layout_width="match_parent"
@@ -51,4 +51,32 @@
 
     </LinearLayout>
 
+    <LinearLayout
+        android:layout_width="600dip"
+        android:layout_height="128dip"
+        android:layout_gravity="center_vertical"
+        android:orientation="horizontal"
+        style="@android:style/Widget.Holo.Spinner"
+        >
+        <LinearLayout
+            android:layout_width="0dip"
+            android:layout_weight="1"
+            android:layout_height="match_parent"
+            android:layout_gravity="center_vertical"
+            android:orientation="vertical"
+            >
+            <TextView
+                android:id="@+id/spinner_line_1"
+                android:layout_width="match_parent"
+                android:layout_height="0dip"
+                android:layout_weight="1"
+                android:textSize="16dip"
+                android:singleLine="true"
+                android:ellipsize="end"
+                android:gravity="left|center_vertical"
+                android:text="@string/button_text"
+                />
+        </LinearLayout>
+    </LinearLayout>
+
 </FrameLayout>
\ No newline at end of file