From 1374b0f66757e47dab3ee5efe85da6c571328ee5 Mon Sep 17 00:00:00 2001 From: behzadbx Date: Sat, 24 Aug 2019 18:48:34 +0430 Subject: [PATCH] Added rtl support --- chocobar/src/main/java/com/pd/chocobar/ChocoBar.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chocobar/src/main/java/com/pd/chocobar/ChocoBar.java b/chocobar/src/main/java/com/pd/chocobar/ChocoBar.java index 7a2fe1b..093dd36 100644 --- a/chocobar/src/main/java/com/pd/chocobar/ChocoBar.java +++ b/chocobar/src/main/java/com/pd/chocobar/ChocoBar.java @@ -3,6 +3,7 @@ import android.app.Activity; import android.content.Context; import android.content.res.ColorStateList; +import android.content.res.Configuration; import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.Drawable; @@ -178,7 +179,11 @@ else if (builder.textColor != null) builder.icon.getIntrinsicHeight()); } - text.setCompoundDrawablesWithIntrinsicBounds(builder.icon, null, transparentHelperDrawable, null); + Configuration configuration = chocolateLayout.getResources().getConfiguration(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && configuration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) + text.setCompoundDrawablesWithIntrinsicBounds(transparentHelperDrawable, null, builder.icon, null); + else + text.setCompoundDrawablesWithIntrinsicBounds(builder.icon, null, transparentHelperDrawable, null); text.setCompoundDrawablePadding(text.getResources().getDimensionPixelOffset(R.dimen.icon_padding)); } @@ -408,4 +413,4 @@ private Snackbar make() { } -} \ No newline at end of file +}