Skip to content

Commit

Permalink
bugfix: TabSegment matchparent.#285
Browse files Browse the repository at this point in the history
  • Loading branch information
cgspine committed May 21, 2018
1 parent 6cfbaf8 commit e533590
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions qmui/src/main/java/com/qmuiteam/qmui/widget/QMUITabSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import android.support.v7.widget.AppCompatTextView;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Pair;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.Gravity;
Expand Down Expand Up @@ -196,7 +194,7 @@ public void onClick(View v) {
private DataSetObserver mPagerAdapterObserver;
private ViewPager.OnPageChangeListener mOnPageChangeListener;
private OnTabSelectedListener mViewPagerSelectedListener;
// private AdapterChangeListener mAdapterChangeListener;
// private AdapterChangeListener mAdapterChangeListener;
private boolean mIsInSelectTab = false;

public QMUITabSegment(Context context) {
Expand Down Expand Up @@ -567,7 +565,7 @@ public void selectTab(int index) {
* 只有点击 tab 才会自己产生动画变化,其它需要使用 updateIndicatorPosition 做驱动
*/
private void selectTab(final int index, boolean preventAnim) {
if(mIsInSelectTab){
if (mIsInSelectTab) {
return;
}
mIsInSelectTab = true;
Expand Down Expand Up @@ -831,13 +829,16 @@ void populateFromPagerAdapter(boolean useAdapterTitle) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);

if (getChildCount() > 0) {
final View child = getChildAt(0);
int paddingHor = getPaddingLeft() + getPaddingRight();
child.measure(MeasureSpec.makeMeasureSpec(widthSize - paddingHor, MeasureSpec.EXACTLY), heightMeasureSpec);
setMeasuredDimension(Math.min(widthSize, child.getMeasuredWidth() + paddingHor), heightMeasureSpec);
return;
if (widthMode == MeasureSpec.AT_MOST) {
setMeasuredDimension(Math.min(widthSize, child.getMeasuredWidth() + paddingHor), heightMeasureSpec);
return;
}
}
setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
}
Expand Down

0 comments on commit e533590

Please sign in to comment.