feat(tabview): add tab text font size properies (#124)

This commit is contained in:
Martin Yankov
2018-05-09 16:44:07 +03:00
committed by Svetoslav
parent a65984f1d5
commit e2003aa9b1
2 changed files with 28 additions and 0 deletions

View File

@@ -147,6 +147,14 @@ public class TabLayout extends HorizontalScrollView {
return mTabStrip.getSelectedTabTextColor(); return mTabStrip.getSelectedTabTextColor();
} }
public void setTabTextFontSize(float fontSize){
mTabStrip.setTabTextFontSize(fontSize);
}
public float getTabTextFontSize(){
return mTabStrip.getTabTextFontSize();
}
/** /**
* Set the {@link ViewPager.OnPageChangeListener}. When using * Set the {@link ViewPager.OnPageChangeListener}. When using
* {@link TabLayout} you are required to set any * {@link TabLayout} you are required to set any

View File

@@ -50,6 +50,7 @@ class TabStrip extends LinearLayout {
private int mTabTextColor; private int mTabTextColor;
private int mSelectedTabTextColor; private int mSelectedTabTextColor;
private float mTabTextFontSize;
TabStrip(Context context) { TabStrip(Context context) {
this(context, null); this(context, null);
@@ -81,6 +82,7 @@ class TabStrip extends LinearLayout {
TextView defaultTextView = new TextView(context); TextView defaultTextView = new TextView(context);
mTabTextColor = defaultTextView.getTextColors().getDefaultColor(); mTabTextColor = defaultTextView.getTextColors().getDefaultColor();
mTabTextFontSize = defaultTextView.getTextSize();
// Default selected color is the same as mTabTextColor // Default selected color is the same as mTabTextColor
mSelectedTabTextColor = mTabTextColor; mSelectedTabTextColor = mTabTextColor;
@@ -132,6 +134,24 @@ class TabStrip extends LinearLayout {
} }
} }
void setTabTextFontSize(float fontSize){
mTabTextFontSize = fontSize;
updateTabsTextFontSize();
}
float getTabTextFontSize(){
return mTabTextFontSize;
}
private void updateTabsTextFontSize(){
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++){
LinearLayout linearLayout = (LinearLayout)getChildAt(i);
TextView textView = (TextView)linearLayout.getChildAt(1);
textView.setTextSize(mTabTextFontSize);
}
}
void onViewPagerPageChanged(int position, float positionOffset) { void onViewPagerPageChanged(int position, float positionOffset) {
mSelectedPosition = position; mSelectedPosition = position;
mSelectionOffset = positionOffset; mSelectionOffset = positionOffset;