mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(tabview): add tab text font size properies (#124)
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user