@@ -142,6 +142,8 @@ public void onScrollChanged() {
142142 };
143143 private int mAnchorXoff , mAnchorYoff ;
144144
145+ private boolean mPopupViewInitialLayoutDirectionInherited ;
146+
145147 /**
146148 * <p>Create a new empty, non focusable popup window of dimension (0,0).</p>
147149 *
@@ -968,6 +970,8 @@ private void preparePopup(WindowManager.LayoutParams p) {
968970 } else {
969971 mPopupView = mContentView ;
970972 }
973+ mPopupViewInitialLayoutDirectionInherited =
974+ (mPopupView .getRawLayoutDirection () == View .LAYOUT_DIRECTION_INHERIT );
971975 mPopupWidth = p .width ;
972976 mPopupHeight = p .height ;
973977 }
@@ -985,9 +989,19 @@ private void invokePopup(WindowManager.LayoutParams p) {
985989 p .packageName = mContext .getPackageName ();
986990 }
987991 mPopupView .setFitsSystemWindows (mLayoutInsetDecor );
992+ setLayoutDirectionFromAnchor ();
988993 mWindowManager .addView (mPopupView , p );
989994 }
990995
996+ private void setLayoutDirectionFromAnchor () {
997+ if (mAnchor != null ) {
998+ View anchor = mAnchor .get ();
999+ if (anchor != null && mPopupViewInitialLayoutDirectionInherited ) {
1000+ mPopupView .setLayoutDirection (anchor .getLayoutDirection ());
1001+ }
1002+ }
1003+ }
1004+
9911005 /**
9921006 * <p>Generate the layout parameters for the popup window.</p>
9931007 *
@@ -1304,8 +1318,9 @@ public void update() {
13041318 p .flags = newFlags ;
13051319 update = true ;
13061320 }
1307-
1321+
13081322 if (update ) {
1323+ setLayoutDirectionFromAnchor ();
13091324 mWindowManager .updateViewLayout (mPopupView , p );
13101325 }
13111326 }
@@ -1406,6 +1421,7 @@ public void update(int x, int y, int width, int height, boolean force) {
14061421 }
14071422
14081423 if (update ) {
1424+ setLayoutDirectionFromAnchor ();
14091425 mWindowManager .updateViewLayout (mPopupView , p );
14101426 }
14111427 }
@@ -1482,7 +1498,7 @@ private void update(View anchor, boolean updateLocation, int xoff, int yoff,
14821498 } else {
14831499 updateAboveAnchor (findDropDownPosition (anchor , p , mAnchorXoff , mAnchorYoff ));
14841500 }
1485-
1501+
14861502 update (p .x , p .y , width , height , x != p .x || y != p .y );
14871503 }
14881504
0 commit comments