Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set SetmentTabLayout indicator draggable #250

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions FlycoTabLayout_Lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ apply plugin: 'com.android.library'
// 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
version = "2.1.2"
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 11
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 27
versionCode 212
versionName version
}
Expand All @@ -23,8 +23,8 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:25.1.0'
api fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:27.1.1'
}

//def siteUrl = 'https://github.com/H07000223' // 项目的主页
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@

import java.util.ArrayList;

/** 没有继承HorizontalScrollView不能滑动,对于ViewPager无依赖 */
/**
* 没有继承HorizontalScrollView不能滑动,对于ViewPager无依赖
*/
public class CommonTabLayout extends FrameLayout implements ValueAnimator.AnimatorUpdateListener {
private Context mContext;
private ArrayList<CustomTabEntity> mTabEntitys = new ArrayList<>();
private LinearLayout mTabsContainer;
private int mCurrentTab;
private int mLastTab;
private int mTabCount;
/** 用于绘制显示器 */
/**
* 用于绘制显示器
*/
private Rect mIndicatorRect = new Rect();
private GradientDrawable mIndicatorDrawable = new GradientDrawable();

Expand All @@ -59,7 +63,9 @@ public class CommonTabLayout extends FrameLayout implements ValueAnimator.Animat
private boolean mTabSpaceEqual;
private float mTabWidth;

/** indicator */
/**
* indicator
*/
private int mIndicatorColor;
private float mIndicatorHeight;
private float mIndicatorWidth;
Expand All @@ -73,17 +79,23 @@ public class CommonTabLayout extends FrameLayout implements ValueAnimator.Animat
private boolean mIndicatorBounceEnable;
private int mIndicatorGravity;

/** underline */
/**
* underline
*/
private int mUnderlineColor;
private float mUnderlineHeight;
private int mUnderlineGravity;

/** divider */
/**
* divider
*/
private int mDividerColor;
private float mDividerWidth;
private float mDividerPadding;

/** title */
/**
* title
*/
private static final int TEXT_BOLD_NONE = 0;
private static final int TEXT_BOLD_WHEN_SELECT = 1;
private static final int TEXT_BOLD_BOTH = 2;
Expand All @@ -93,7 +105,9 @@ public class CommonTabLayout extends FrameLayout implements ValueAnimator.Animat
private int mTextBold;
private boolean mTextAllCaps;

/** icon */
/**
* icon
*/
private boolean mIconVisible;
private int mIconGravity;
private float mIconWidth;
Expand All @@ -102,7 +116,9 @@ public class CommonTabLayout extends FrameLayout implements ValueAnimator.Animat

private int mHeight;

/** anim */
/**
* anim
*/
private ValueAnimator mValueAnimator;
private OvershootInterpolator mInterpolator = new OvershootInterpolator(1.5f);

Expand Down Expand Up @@ -190,7 +206,7 @@ private void obtainAttributes(Context context, AttributeSet attrs) {
ta.recycle();
}

public void setTabData(ArrayList<CustomTabEntity> tabEntitys) {
public void setTabData(ArrayList<? extends CustomTabEntity> tabEntitys) {
if (tabEntitys == null || tabEntitys.size() == 0) {
throw new IllegalStateException("TabEntitys can not be NULL or EMPTY !");
}
Expand All @@ -201,13 +217,17 @@ public void setTabData(ArrayList<CustomTabEntity> tabEntitys) {
notifyDataSetChanged();
}

/** 关联数据支持同时切换fragments */
public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
/**
* 关联数据支持同时切换fragments
*/
public void setTabData(ArrayList<? extends CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<? extends Fragment> fragments) {
mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
setTabData(tabEntitys);
}

/** 更新数据 */
/**
* 更新数据
*/
public void notifyDataSetChanged() {
mTabsContainer.removeAllViews();
this.mTabCount = mTabEntitys.size();
Expand All @@ -230,7 +250,9 @@ public void notifyDataSetChanged() {
updateTabStyles();
}

/** 创建并添加tab */
/**
* 创建并添加tab
*/
private void addTab(final int position, View tabView) {
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tv_tab_title.setText(mTabEntitys.get(position).getTabTitle());
Expand All @@ -242,9 +264,12 @@ private void addTab(final int position, View tabView) {
public void onClick(View v) {
int position = (Integer) v.getTag();
if (mCurrentTab != position) {
setCurrentTab(position);
boolean b = false;
if (mListener != null) {
mListener.onTabSelect(position);
b = mListener.onTabSelect(position);
}
if (!b) {
setCurrentTab(position);
}
} else {
if (mListener != null) {
Expand Down Expand Up @@ -885,7 +910,9 @@ public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
}
}

/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置 */
/**
* 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置
*/
public MsgView getMsgView(int position) {
if (position >= mTabCount) {
position = mTabCount - 1;
Expand Down
Loading