Android 标签栏pagerslidingtabstrip用法实例(含Demo)

举报
再见孙悟空_ 发表于 2022/01/13 23:10:13 2022/01/13
【摘要】   (效果图来源于自己写的demo,双击可放大) 大家肯定对这种可滑动的导航标题并不陌生,项目中经常需要用到这种滑动切换的效果,我觉得PagerSlidingTabStrip搭配viewPager的组合最好用了。PagerSlidingTabStrip是一个开源框架,和github上面的其他开源框架使用方法一样 开源...

 

(效果图来源于自己写的demo,双击可放大)

大家肯定对这种可滑动的导航标题并不陌生,项目中经常需要用到这种滑动切换的效果,我觉得PagerSlidingTabStrip搭配viewPager的组合最好用了。PagerSlidingTabStrip是一个开源框架,和github上面的其他开源框架使用方法一样

开源框架地址:GitHub - astuetz/PagerSlidingTabStrip: An interactive indicator to navigate between the different pages of a ViewPager

我自己习惯用eclipse写个demo,将核心源码拷贝到项目中方便查看,话不多说,上代码

核心的类PagerSlidingTabStrip


  
  1. package com.baobao.pagerslidingtabstrip;
  2. import android.content.Context;
  3. import android.content.res.TypedArray;
  4. import android.graphics.Canvas;
  5. import android.graphics.Paint;
  6. import android.graphics.Paint.Style;
  7. import android.graphics.Typeface;
  8. import android.os.Build;
  9. import android.os.Parcel;
  10. import android.os.Parcelable;
  11. import android.support.v4.view.ViewPager;
  12. import android.support.v4.view.ViewPager.OnPageChangeListener;
  13. import android.util.AttributeSet;
  14. import android.util.DisplayMetrics;
  15. import android.util.TypedValue;
  16. import android.view.Gravity;
  17. import android.view.View;
  18. import android.view.ViewTreeObserver.OnGlobalLayoutListener;
  19. import android.widget.HorizontalScrollView;
  20. import android.widget.ImageButton;
  21. import android.widget.LinearLayout;
  22. import android.widget.TextView;
  23. import java.util.Locale;
  24. public class PagerSlidingTabStrip extends HorizontalScrollView {
  25. public interface IconTabProvider {
  26. public int getPageIconResId(int position);
  27. }
  28. // @formatter:off
  29. private static final int[] ATTRS = new int[] { android.R.attr.textSize,
  30. android.R.attr.textColor };
  31. // @formatter:on
  32. private LinearLayout.LayoutParams defaultTabLayoutParams;
  33. private LinearLayout.LayoutParams expandedTabLayoutParams;
  34. private final PageListener pageListener = new PageListener();
  35. public OnPageChangeListener delegatePageListener;
  36. private LinearLayout tabsContainer;
  37. private ViewPager pager;
  38. private int tabCount;
  39. private int currentPosition = 0;
  40. private int selectedPosition = 0;
  41. private float currentPositionOffset = 0f;
  42. private Paint rectPaint;
  43. private Paint dividerPaint;
  44. private int indicatorColor = 0xFF666666;
  45. private int underlineColor = 0x1A000000;
  46. private int dividerColor = 0x1A000000;
  47. private boolean shouldExpand = false;
  48. private boolean textAllCaps = true;
  49. private int scrollOffset = 52;
  50. private int indicatorHeight = 8;
  51. private int underlineHeight = 2;
  52. private int dividerPadding = 12;
  53. private int tabPadding = 24;
  54. private int dividerWidth = 1;
  55. private int tabTextSize = 12;
  56. private int tabTextColor = 0xFF666666;
  57. private int selectedTabTextColor = 0xFF666666;
  58. private Typeface tabTypeface = null;
  59. private int tabTypefaceStyle = Typeface.NORMAL;
  60. private int lastScrollX = 0;
  61. private int tabBackgroundResId = R.drawable.background_tab;
  62. private Locale locale;
  63. public PagerSlidingTabStrip(Context context) {
  64. this(context, null);
  65. }
  66. public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
  67. this(context, attrs, 0);
  68. }
  69. public PagerSlidingTabStrip(Context context, AttributeSet attrs,
  70. int defStyle) {
  71. super(context, attrs, defStyle);
  72. setFillViewport(true);
  73. setWillNotDraw(false);
  74. tabsContainer = new LinearLayout(context);
  75. tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
  76. tabsContainer.setLayoutParams(new LayoutParams(
  77. LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  78. addView(tabsContainer);
  79. DisplayMetrics dm = getResources().getDisplayMetrics();
  80. scrollOffset = (int) TypedValue.applyDimension(
  81. TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
  82. indicatorHeight = (int) TypedValue.applyDimension(
  83. TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
  84. underlineHeight = (int) TypedValue.applyDimension(
  85. TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
  86. dividerPadding = (int) TypedValue.applyDimension(
  87. TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
  88. tabPadding = (int) TypedValue.applyDimension(
  89. TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
  90. dividerWidth = (int) TypedValue.applyDimension(
  91. TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
  92. tabTextSize = (int) TypedValue.applyDimension(
  93. TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);
  94. // get system attrs (android:textSize and android:textColor)
  95. TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
  96. tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
  97. tabTextColor = a.getColor(1, tabTextColor);
  98. a.recycle();
  99. // get custom attrs
  100. a = context.obtainStyledAttributes(attrs,
  101. R.styleable.PagerSlidingTabStrip);
  102. indicatorColor = a.getColor(
  103. R.styleable.PagerSlidingTabStrip_pstsIndicatorColor,
  104. indicatorColor);
  105. underlineColor = a.getColor(
  106. R.styleable.PagerSlidingTabStrip_pstsUnderlineColor,
  107. underlineColor);
  108. dividerColor = a
  109. .getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor,
  110. dividerColor);
  111. indicatorHeight = a.getDimensionPixelSize(
  112. R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
  113. indicatorHeight);
  114. underlineHeight = a.getDimensionPixelSize(
  115. R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
  116. underlineHeight);
  117. dividerPadding = a.getDimensionPixelSize(
  118. R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
  119. dividerPadding);
  120. tabPadding = a.getDimensionPixelSize(
  121. R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight,
  122. tabPadding);
  123. tabBackgroundResId = a.getResourceId(
  124. R.styleable.PagerSlidingTabStrip_pstsTabBackground,
  125. tabBackgroundResId);
  126. shouldExpand = a
  127. .getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand,
  128. shouldExpand);
  129. scrollOffset = a
  130. .getDimensionPixelSize(
  131. R.styleable.PagerSlidingTabStrip_pstsScrollOffset,
  132. scrollOffset);
  133. textAllCaps = a.getBoolean(
  134. R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
  135. a.recycle();
  136. rectPaint = new Paint();
  137. rectPaint.setAntiAlias(true);
  138. rectPaint.setStyle(Style.FILL);
  139. dividerPaint = new Paint();
  140. dividerPaint.setAntiAlias(true);
  141. dividerPaint.setStrokeWidth(dividerWidth);
  142. defaultTabLayoutParams = new LinearLayout.LayoutParams(
  143. LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
  144. expandedTabLayoutParams = new LinearLayout.LayoutParams(0,
  145. LayoutParams.MATCH_PARENT, 1.0f);
  146. if (locale == null) {
  147. locale = getResources().getConfiguration().locale;
  148. }
  149. }
  150. public void setViewPager(ViewPager pager) {
  151. this.pager = pager;
  152. if (pager.getAdapter() == null) {
  153. throw new IllegalStateException(
  154. "ViewPager does not have adapter instance.");
  155. }
  156. pager.setOnPageChangeListener(pageListener);
  157. notifyDataSetChanged();
  158. }
  159. public void setOnPageChangeListener(OnPageChangeListener listener) {
  160. this.delegatePageListener = listener;
  161. }
  162. public void notifyDataSetChanged() {
  163. tabsContainer.removeAllViews();
  164. tabCount = pager.getAdapter().getCount();
  165. for (int i = 0; i < tabCount; i++) {
  166. if (pager.getAdapter() instanceof IconTabProvider) {
  167. addIconTab(i,
  168. ((IconTabProvider) pager.getAdapter())
  169. .getPageIconResId(i));
  170. } else {
  171. addTextTab(i, pager.getAdapter().getPageTitle(i).toString());
  172. }
  173. }
  174. updateTabStyles();
  175. getViewTreeObserver().addOnGlobalLayoutListener(
  176. new OnGlobalLayoutListener() {
  177. @Override
  178. public void onGlobalLayout() {
  179. getViewTreeObserver()
  180. .removeGlobalOnLayoutListener(this);
  181. currentPosition = pager.getCurrentItem();
  182. scrollToChild(currentPosition, 0);
  183. }
  184. });
  185. }
  186. private void addTextTab(final int position, String title) {
  187. TextView tab = new TextView(getContext());
  188. tab.setText(title);
  189. tab.setGravity(Gravity.CENTER);
  190. tab.setSingleLine();
  191. addTab(position, tab);
  192. }
  193. private void addIconTab(final int position, int resId) {
  194. ImageButton tab = new ImageButton(getContext());
  195. tab.setImageResource(resId);
  196. addTab(position, tab);
  197. }
  198. private void addTab(final int position, View tab) {
  199. tab.setFocusable(true);
  200. tab.setOnClickListener(new OnClickListener() {
  201. @Override
  202. public void onClick(View v) {
  203. pager.setCurrentItem(position);
  204. }
  205. });
  206. tab.setPadding(tabPadding, 0, tabPadding, 0);
  207. tabsContainer
  208. .addView(tab, position, shouldExpand ? expandedTabLayoutParams
  209. : defaultTabLayoutParams);
  210. }
  211. private void updateTabStyles() {
  212. for (int i = 0; i < tabCount; i++) {
  213. View v = tabsContainer.getChildAt(i);
  214. v.setBackgroundResource(tabBackgroundResId);
  215. if (v instanceof TextView) {
  216. TextView tab = (TextView) v;
  217. tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
  218. tab.setTypeface(tabTypeface, tabTypefaceStyle);
  219. tab.setTextColor(tabTextColor);
  220. // setAllCaps() is only available from API 14, so the upper case
  221. // is made manually if we are on a
  222. // pre-ICS-build
  223. if (textAllCaps) {
  224. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
  225. tab.setAllCaps(true);
  226. } else {
  227. tab.setText(tab.getText().toString()
  228. .toUpperCase(locale));
  229. }
  230. }
  231. if (i == selectedPosition) {
  232. tab.setTextColor(selectedTabTextColor);
  233. }
  234. }
  235. }
  236. }
  237. private void scrollToChild(int position, int offset) {
  238. if (tabCount == 0) {
  239. return;
  240. }
  241. int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset;
  242. if (position > 0 || offset > 0) {
  243. newScrollX -= scrollOffset;
  244. }
  245. if (newScrollX != lastScrollX) {
  246. lastScrollX = newScrollX;
  247. scrollTo(newScrollX, 0);
  248. }
  249. }
  250. @Override
  251. protected void onDraw(Canvas canvas) {
  252. super.onDraw(canvas);
  253. if (isInEditMode() || tabCount == 0) {
  254. return;
  255. }
  256. final int height = getHeight();
  257. // draw underline
  258. rectPaint.setColor(underlineColor);
  259. canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(),
  260. height, rectPaint);
  261. // draw indicator line
  262. rectPaint.setColor(indicatorColor);
  263. // default: line below current tab
  264. View currentTab = tabsContainer.getChildAt(currentPosition);
  265. float lineLeft = currentTab.getLeft();
  266. float lineRight = currentTab.getRight();
  267. // if there is an offset, start interpolating left and right coordinates
  268. // between current and next tab
  269. if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
  270. View nextTab = tabsContainer.getChildAt(currentPosition + 1);
  271. final float nextTabLeft = nextTab.getLeft();
  272. final float nextTabRight = nextTab.getRight();
  273. lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset)
  274. * lineLeft);
  275. lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset)
  276. * lineRight);
  277. }
  278. canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height,
  279. rectPaint);
  280. // draw divider
  281. dividerPaint.setColor(dividerColor);
  282. for (int i = 0; i < tabCount - 1; i++) {
  283. View tab = tabsContainer.getChildAt(i);
  284. canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(),
  285. height - dividerPadding, dividerPaint);
  286. }
  287. }
  288. private class PageListener implements OnPageChangeListener {
  289. @Override
  290. public void onPageScrolled(int position, float positionOffset,
  291. int positionOffsetPixels) {
  292. currentPosition = position;
  293. currentPositionOffset = positionOffset;
  294. scrollToChild(position, (int) (positionOffset * tabsContainer
  295. .getChildAt(position).getWidth()));
  296. invalidate();
  297. if (delegatePageListener != null) {
  298. delegatePageListener.onPageScrolled(position, positionOffset,
  299. positionOffsetPixels);
  300. }
  301. }
  302. @Override
  303. public void onPageScrollStateChanged(int state) {
  304. if (state == ViewPager.SCROLL_STATE_IDLE) {
  305. scrollToChild(pager.getCurrentItem(), 0);
  306. }
  307. if (delegatePageListener != null) {
  308. delegatePageListener.onPageScrollStateChanged(state);
  309. }
  310. }
  311. @Override
  312. public void onPageSelected(int position) {
  313. selectedPosition = position;
  314. updateTabStyles();
  315. if (delegatePageListener != null) {
  316. delegatePageListener.onPageSelected(position);
  317. }
  318. }
  319. }
  320. public void setSelectedPosition(int selectedPosition) {
  321. this.selectedPosition = selectedPosition;
  322. }
  323. public void setIndicatorColor(int indicatorColor) {
  324. this.indicatorColor = indicatorColor;
  325. invalidate();
  326. }
  327. public void setIndicatorColorResource(int resId) {
  328. this.indicatorColor = getResources().getColor(resId);
  329. invalidate();
  330. }
  331. public int getIndicatorColor() {
  332. return this.indicatorColor;
  333. }
  334. public void setIndicatorHeight(int indicatorLineHeightPx) {
  335. this.indicatorHeight = indicatorLineHeightPx;
  336. invalidate();
  337. }
  338. public int getIndicatorHeight() {
  339. return indicatorHeight;
  340. }
  341. public void setUnderlineColor(int underlineColor) {
  342. this.underlineColor = underlineColor;
  343. invalidate();
  344. }
  345. public void setUnderlineColorResource(int resId) {
  346. this.underlineColor = getResources().getColor(resId);
  347. invalidate();
  348. }
  349. public int getUnderlineColor() {
  350. return underlineColor;
  351. }
  352. public void setDividerColor(int dividerColor) {
  353. this.dividerColor = dividerColor;
  354. invalidate();
  355. }
  356. public void setDividerColorResource(int resId) {
  357. this.dividerColor = getResources().getColor(resId);
  358. invalidate();
  359. }
  360. public int getDividerColor() {
  361. return dividerColor;
  362. }
  363. public void setUnderlineHeight(int underlineHeightPx) {
  364. this.underlineHeight = underlineHeightPx;
  365. invalidate();
  366. }
  367. public int getUnderlineHeight() {
  368. return underlineHeight;
  369. }
  370. public void setDividerPadding(int dividerPaddingPx) {
  371. this.dividerPadding = dividerPaddingPx;
  372. invalidate();
  373. }
  374. public int getDividerPadding() {
  375. return dividerPadding;
  376. }
  377. public void setScrollOffset(int scrollOffsetPx) {
  378. this.scrollOffset = scrollOffsetPx;
  379. invalidate();
  380. }
  381. public int getScrollOffset() {
  382. return scrollOffset;
  383. }
  384. public void setShouldExpand(boolean shouldExpand) {
  385. this.shouldExpand = shouldExpand;
  386. notifyDataSetChanged();
  387. }
  388. public boolean getShouldExpand() {
  389. return shouldExpand;
  390. }
  391. public boolean isTextAllCaps() {
  392. return textAllCaps;
  393. }
  394. public void setAllCaps(boolean textAllCaps) {
  395. this.textAllCaps = textAllCaps;
  396. }
  397. public void setTextSize(int textSizePx) {
  398. this.tabTextSize = textSizePx;
  399. updateTabStyles();
  400. }
  401. public int getTextSize() {
  402. return tabTextSize;
  403. }
  404. public void setTextColor(int textColor) {
  405. this.tabTextColor = textColor;
  406. updateTabStyles();
  407. }
  408. public void setTextColorResource(int resId) {
  409. this.tabTextColor = getResources().getColor(resId);
  410. updateTabStyles();
  411. }
  412. public int getTextColor() {
  413. return tabTextColor;
  414. }
  415. public void setSelectedTextColor(int textColor) {
  416. this.selectedTabTextColor = textColor;
  417. updateTabStyles();
  418. }
  419. public void setSelectedTextColorResource(int resId) {
  420. this.selectedTabTextColor = getResources().getColor(resId);
  421. updateTabStyles();
  422. }
  423. public int getSelectedTextColor() {
  424. return selectedTabTextColor;
  425. }
  426. public void setTypeface(Typeface typeface, int style) {
  427. this.tabTypeface = typeface;
  428. this.tabTypefaceStyle = style;
  429. updateTabStyles();
  430. }
  431. public void setTabBackground(int resId) {
  432. this.tabBackgroundResId = resId;
  433. updateTabStyles();
  434. }
  435. public int getTabBackground() {
  436. return tabBackgroundResId;
  437. }
  438. public void setTabPaddingLeftRight(int paddingPx) {
  439. this.tabPadding = paddingPx;
  440. updateTabStyles();
  441. }
  442. public int getTabPaddingLeftRight() {
  443. return tabPadding;
  444. }
  445. @Override
  446. public void onRestoreInstanceState(Parcelable state) {
  447. SavedState savedState = (SavedState) state;
  448. super.onRestoreInstanceState(savedState.getSuperState());
  449. currentPosition = savedState.currentPosition;
  450. requestLayout();
  451. }
  452. @Override
  453. public Parcelable onSaveInstanceState() {
  454. Parcelable superState = super.onSaveInstanceState();
  455. SavedState savedState = new SavedState(superState);
  456. savedState.currentPosition = currentPosition;
  457. return savedState;
  458. }
  459. static class SavedState extends BaseSavedState {
  460. int currentPosition;
  461. public SavedState(Parcelable superState) {
  462. super(superState);
  463. }
  464. private SavedState(Parcel in) {
  465. super(in);
  466. currentPosition = in.readInt();
  467. }
  468. @Override
  469. public void writeToParcel(Parcel dest, int flags) {
  470. super.writeToParcel(dest, flags);
  471. dest.writeInt(currentPosition);
  472. }
  473. public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
  474. @Override
  475. public SavedState createFromParcel(Parcel in) {
  476. return new SavedState(in);
  477. }
  478. @Override
  479. public SavedState[] newArray(int size) {
  480. return new SavedState[size];
  481. }
  482. };
  483. }
  484. }

xml布局中直接引用


  
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:orientation="vertical"
  5. android:layout_height="match_parent">
  6. <com.baobao.pagerslidingtabstrip.PagerSlidingTabStrip
  7. android:id="@+id/slide_tabs"
  8. android:layout_width="match_parent"
  9. android:layout_height="40dp"/>
  10. <android.support.v4.view.ViewPager
  11. android:id="@+id/slide_pager"
  12. android:layout_width="match_parent"
  13. android:layout_height="match_parent" />
  14. </LinearLayout>

Activity代码


  
  1. package com.baobao.pagerslidingtabstrip;
  2. import android.os.Bundle;
  3. import android.support.v4.app.FragmentActivity;
  4. import android.support.v4.view.ViewPager;
  5. import android.util.DisplayMetrics;
  6. import android.util.TypedValue;
  7. public class MainActivity extends FragmentActivity {
  8. private static final int VIEW_PAGE_SIZE = 8;
  9. private PagerSlidingTabStrip mSlideTabs;
  10. private DisplayMetrics mDm;
  11. private ViewPager mSlidePager;
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_main);
  16. //初始化 标签栏
  17. mDm = getResources().getDisplayMetrics();
  18. mSlidePager = (ViewPager) findViewById(R.id.slide_pager);
  19. mSlideTabs = (PagerSlidingTabStrip) findViewById(R.id.slide_tabs);
  20. if (mSlidePager.getAdapter() == null) {
  21. mSlidePager.setOffscreenPageLimit(VIEW_PAGE_SIZE);
  22. mSlidePager.setAdapter(new TabPageIndicatorAdapter(getSupportFragmentManager()));
  23. }
  24. mSlideTabs.setViewPager(mSlidePager);
  25. setTabsValue();
  26. }
  27. /**
  28. * 设置PagerSlidingTabStrip的样式
  29. */
  30. private void setTabsValue() {
  31. // 设置Tab是自动填充满屏幕的
  32. mSlideTabs.setShouldExpand(true);
  33. // 设置Tab的分割线是透明的
  34. //tabs.setDividerColor(Color.TRANSPARENT);
  35. // 设置Tab底部线的高度
  36. mSlideTabs.setUnderlineHeight((int) TypedValue.applyDimension(
  37. TypedValue.COMPLEX_UNIT_DIP, 2, mDm));
  38. // 设置Tab Indicator的高度
  39. mSlideTabs.setIndicatorHeight((int) TypedValue.applyDimension(
  40. TypedValue.COMPLEX_UNIT_DIP, 1, mDm));
  41. // 设置Tab标题文字的大小
  42. mSlideTabs.setTextSize((int) TypedValue.applyDimension(
  43. TypedValue.COMPLEX_UNIT_SP, 14, mDm));
  44. // 设置Tab Indicator的颜色
  45. mSlideTabs.setIndicatorColor(getResources().getColor(R.color.common_blue));
  46. // 设置选中Tab文字的颜色 (这是我自定义的一个方法)
  47. mSlideTabs.setSelectedTextColor(getResources().getColor(R.color.common_blue));
  48. // 取消点击Tab时的背景色
  49. mSlideTabs.setTabBackground(0);
  50. }
  51. }

样式文件 attrs.xml


  
  1. <resources>
  2. <declare-styleable name="Themes">
  3. <attr name="numberProgressBarStyle" format="reference" />
  4. </declare-styleable>
  5. <declare-styleable name="mGallery">
  6. <attr name="android:galleryItemBackground" />
  7. </declare-styleable>
  8. <declare-styleable name="PagerSlidingTabStrip">
  9. <attr name="pstsIndicatorColor" format="color" />
  10. <attr name="pstsUnderlineColor" format="color" />
  11. <attr name="pstsDividerColor" format="color" />
  12. <attr name="pstsIndicatorHeight" format="dimension" />
  13. <attr name="pstsUnderlineHeight" format="dimension" />
  14. <attr name="pstsDividerPadding" format="dimension" />
  15. <attr name="pstsTabPaddingLeftRight" format="dimension" />
  16. <attr name="pstsScrollOffset" format="dimension" />
  17. <attr name="pstsTabBackground" format="reference" />
  18. <attr name="pstsShouldExpand" format="boolean" />
  19. <attr name="pstsTextAllCaps" format="boolean" />
  20. </declare-styleable>
  21. </resources>

效果图如上图,希望可以帮助到大家,如果大家还有其他问题欢迎加入我的qq群讨论交流:

开发一群:454430053开发二群:537532956

文章来源: wukong.blog.csdn.net,作者:再见孙悟空_,版权归原作者所有,如需转载,请联系作者。

原文链接:wukong.blog.csdn.net/article/details/79360351

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200