diff --git a/library/src/main/java/info/hoang8f/android/segmented/SegmentedGroup.java b/library/src/main/java/info/hoang8f/android/segmented/SegmentedGroup.java index 0cb1a0a..3343920 100644 --- a/library/src/main/java/info/hoang8f/android/segmented/SegmentedGroup.java +++ b/library/src/main/java/info/hoang8f/android/segmented/SegmentedGroup.java @@ -256,22 +256,46 @@ private int getChildIndex(View view) { } private void setChildRadii(int newChildren, int newChild) { - + // If same values are passed, just return. No need to update anything if (children == newChildren && child == newChild) return; - + // Set the new values children = newChildren; child = newChild; - + + // is Left-To-Right language + final boolean isLTR; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + isLTR = (TextUtils.getLayoutDirectionFromLocale(getContext().getResources().getConfiguration().locale) == LAYOUT_DIRECTION_LTR); + } + else { + isLTR = true; + } // if there is only one child provide the default radio button if (children == 1) { radii = rDefault; } else if (child == 0) { //left or top - radii = (getOrientation() == LinearLayout.HORIZONTAL) ? rLeft : rTop; + if(getOrientation() == LinearLayout.HORIZONTAL) { + if(isLTR) + radii = rLeft; + else + radii = rRight; + } + else { + radii = rTop; + } } else if (child == children - 1) { //right or bottom - radii = (getOrientation() == LinearLayout.HORIZONTAL) ? rRight : rBot; + if(getOrientation() == LinearLayout.HORIZONTAL) { + if(isLTR) + radii = rRight; + else + radii = rLeft; + } + else { + radii = rBot; + } } else { //middle radii = rMiddle; }