Fix RTL issue of ImageFloatingTextView
am: dd8611fc5a
Change-Id: I101527b922604640fef684c6216b99289ac97f25
This commit is contained in:
@@ -40,6 +40,9 @@ public class ImageFloatingTextView extends TextView {
|
|||||||
/** Number of lines from the top to indent */
|
/** Number of lines from the top to indent */
|
||||||
private int mIndentLines;
|
private int mIndentLines;
|
||||||
|
|
||||||
|
/** Resolved layout direction */
|
||||||
|
private int mResolvedDirection = LAYOUT_DIRECTION_UNDEFINED;
|
||||||
|
|
||||||
public ImageFloatingTextView(Context context) {
|
public ImageFloatingTextView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
@@ -82,7 +85,7 @@ public class ImageFloatingTextView extends TextView {
|
|||||||
margins[i] = endMargin;
|
margins[i] = endMargin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
|
if (mResolvedDirection == LAYOUT_DIRECTION_RTL) {
|
||||||
builder.setIndents(margins, null);
|
builder.setIndents(margins, null);
|
||||||
} else {
|
} else {
|
||||||
builder.setIndents(null, margins);
|
builder.setIndents(null, margins);
|
||||||
@@ -91,6 +94,19 @@ public class ImageFloatingTextView extends TextView {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRtlPropertiesChanged(int layoutDirection) {
|
||||||
|
super.onRtlPropertiesChanged(layoutDirection);
|
||||||
|
|
||||||
|
if (layoutDirection != mResolvedDirection && isLayoutDirectionResolved()) {
|
||||||
|
mResolvedDirection = layoutDirection;
|
||||||
|
if (mIndentLines > 0) {
|
||||||
|
// Invalidate layout.
|
||||||
|
setHint(getHint());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@RemotableViewMethod
|
@RemotableViewMethod
|
||||||
public void setHasImage(boolean hasImage) {
|
public void setHasImage(boolean hasImage) {
|
||||||
setNumIndentLines(hasImage ? 2 : 0);
|
setNumIndentLines(hasImage ? 2 : 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user