Skip to content

Commit fcc3348

Browse files
author
Fabrice Di Meglio
committed
Fix bug #7374285 GridLayout layout param margins are broken in RTL mode
- resolve layout params in ViewGroup when layout direction is changed - layout param resolution is checking the previous layout direction to check if we need to resolve Change-Id: I70af2ad2b4ec83c2ec6c93b3ff445852500d1687
1 parent fc2652e commit fcc3348

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

core/java/android/view/View.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10002,8 +10002,10 @@ public void setLayoutParams(ViewGroup.LayoutParams params) {
1000210002

1000310003
/**
1000410004
* Resolve the layout parameters depending on the resolved layout direction
10005+
*
10006+
* @hide
1000510007
*/
10006-
private void resolveLayoutParams() {
10008+
public void resolveLayoutParams() {
1000710009
if (mLayoutParams != null) {
1000810010
mLayoutParams.resolveLayoutDirection(getLayoutDirection());
1000910011
}

core/java/android/view/ViewGroup.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,6 +5358,16 @@ protected void resolveDrawables() {
53585358
}
53595359
}
53605360

5361+
@Override
5362+
public void resolveLayoutParams() {
5363+
super.resolveLayoutParams();
5364+
int count = getChildCount();
5365+
for (int i = 0; i < count; i++) {
5366+
final View child = getChildAt(i);
5367+
child.resolveLayoutParams();
5368+
}
5369+
}
5370+
53615371
/**
53625372
* @hide
53635373
*/
@@ -5981,6 +5991,11 @@ public int getLayoutDirection() {
59815991
*/
59825992
@Override
59835993
public void resolveLayoutDirection(int layoutDirection) {
5994+
// No need to resolve if it is the same layout direction as before
5995+
if (this.layoutDirection == layoutDirection) {
5996+
return;
5997+
}
5998+
59845999
setLayoutDirection(layoutDirection);
59856000

59866001
if (!isMarginRelative()) return;

0 commit comments

Comments
 (0)