18
18
import android .support .annotation .Nullable ;
19
19
import android .support .v4 .content .ContextCompat ;
20
20
import android .support .v4 .graphics .drawable .DrawableCompat ;
21
+ import android .support .v4 .text .TextUtilsCompat ;
22
+ import android .support .v4 .view .ViewCompat ;
21
23
import android .support .v7 .content .res .AppCompatResources ;
22
24
import android .support .v7 .widget .AppCompatTextView ;
23
25
import android .util .AttributeSet ;
24
26
27
+ import java .util .Locale ;
28
+
25
29
/**
26
30
* You can use a vector drawable in TextView instead of drawableLeft, drawableTop, drawableRight and
27
31
* drawableBottom.
@@ -176,7 +180,7 @@ public void setIconColor(@ColorInt final int color) {
176
180
/**
177
181
* Change drawable icon size
178
182
*
179
- * @param widthRes Set width resource id
183
+ * @param widthRes Set width resource id
180
184
* @param heightRes Set height resource id
181
185
*/
182
186
public void setIconSizeResource (@ DimenRes final int widthRes , @ DimenRes final int heightRes ) {
@@ -187,7 +191,7 @@ public void setIconSizeResource(@DimenRes final int widthRes, @DimenRes final in
187
191
/**
188
192
* Change drawable icon size
189
193
*
190
- * @param width Set width size
194
+ * @param width Set width size
191
195
* @param height Set height size
192
196
*/
193
197
public void setIconSize (@ Dimension final int width , @ Dimension final int height ) {
@@ -302,4 +306,12 @@ private static void fixVectorDrawableTinting(final Drawable drawable) {
302
306
// Now set the original state
303
307
drawable .setState (originalState );
304
308
}
309
+
310
+ private boolean isRtl () {
311
+ Resources resources = getContext ().getResources ();
312
+ Locale locale = Build .VERSION .SDK_INT >= Build .VERSION_CODES .N
313
+ ? resources .getConfiguration ().getLocales ().getFirstMatch (resources .getAssets ().getLocales ())
314
+ : resources .getConfiguration ().locale ;
315
+ return TextUtilsCompat .getLayoutDirectionFromLocale (locale ) == ViewCompat .LAYOUT_DIRECTION_RTL ;
316
+ }
305
317
}
0 commit comments