diff --git a/.gitignore b/.gitignore index 9c4de58..31df7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ .DS_Store /build /captures +/.idea/inspectionProfiles/ +/.idea/smartfox_info.xml + diff --git a/.idea/gradle.xml b/.idea/gradle.xml index ff65e73..25e8f3d 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -7,9 +7,9 @@ - - - + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index cca2cda..cc72de3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - @@ -27,17 +24,7 @@ - - - - - - - - - - - + diff --git a/.idea/modules.xml b/.idea/modules.xml index e744d2b..4fb344c 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,9 +2,12 @@ - - - + + + + + + \ No newline at end of file diff --git a/FlowLayout.iml b/FlowLayout.iml index 9df424a..2046591 100644 --- a/FlowLayout.iml +++ b/FlowLayout.iml @@ -1,5 +1,5 @@ - + diff --git a/flowlayout-lib/build.gradle b/flowlayout-lib/build.gradle index 7f985d0..31ef8a6 100644 --- a/flowlayout-lib/build.gradle +++ b/flowlayout-lib/build.gradle @@ -20,7 +20,8 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') + compile 'com.android.support:support-v4:25.0.0' } publish { diff --git a/flowlayout-lib/flowlayout-lib.iml b/flowlayout-lib/flowlayout-lib.iml index d467457..3f22574 100644 --- a/flowlayout-lib/flowlayout-lib.iml +++ b/flowlayout-lib/flowlayout-lib.iml @@ -1,5 +1,5 @@ - + @@ -9,7 +9,6 @@ - @@ -20,11 +19,11 @@ - + - + @@ -48,7 +47,6 @@ - @@ -56,7 +54,6 @@ - @@ -64,43 +61,55 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - + + + + + + + + \ No newline at end of file diff --git a/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/FlowLayout.java b/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/FlowLayout.java index d865c62..57850b5 100755 --- a/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/FlowLayout.java +++ b/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/FlowLayout.java @@ -3,11 +3,15 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; +import android.util.LayoutDirection; import android.view.View; import android.view.ViewGroup; +import android.support.v4.text.TextUtilsCompat; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Locale; public class FlowLayout extends ViewGroup { private static final String TAG = "FlowLayout"; @@ -25,6 +29,14 @@ public FlowLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TagFlowLayout); mGravity = ta.getInt(R.styleable.TagFlowLayout_tag_gravity, LEFT); + int layoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()); + if (layoutDirection == LayoutDirection.RTL) { + if (mGravity == LEFT) { + mGravity = RIGHT; + } else { + mGravity = LEFT; + } + } ta.recycle(); } @@ -155,7 +167,10 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) { left = (width - currentLineWidth) / 2 + getPaddingLeft(); break; case RIGHT: - left = width - currentLineWidth + getPaddingLeft(); + // 适配了rtl,需要补偿一个padding值 + left = width - (currentLineWidth + getPaddingLeft()) - getPaddingRight(); + // 适配了rtl,需要把lineViews里面的数组倒序排 + Collections.reverse(lineViews); break; } diff --git a/flowlayout/flowlayout.iml b/flowlayout/flowlayout.iml index 3474d7e..33086c4 100644 --- a/flowlayout/flowlayout.iml +++ b/flowlayout/flowlayout.iml @@ -1,5 +1,5 @@ - + @@ -9,7 +9,6 @@ - @@ -23,7 +22,7 @@ - + @@ -47,7 +46,6 @@ - @@ -55,7 +53,6 @@ - @@ -63,25 +60,22 @@ - - - - - - - - - - + + + + + + + @@ -112,22 +106,22 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + \ No newline at end of file AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル