当前位置: 首页 > news >正文

wordpress技术分析天津seo排名费用

wordpress技术分析,天津seo排名费用,网站背景动图怎么做,什么网站免费做简历模板前言 原生 TabLayout 的指示器长度是充满整个屏幕的,但在实际开发中 UI 会设计成 指示器的长度等于或者小于标题字体长度,如图 如果设置成跟字体长度一样即使用 API: mTabLayout.setTabIndicatorFullWidth(false);或者在 xml 布局文件中的TabLayout标签…

前言

原生 TabLayout 的指示器长度是充满整个屏幕的,但在实际开发中 UI 会设计成 指示器的长度等于或者小于标题字体长度,如图

如果设置成跟字体长度一样即使用 API:

mTabLayout.setTabIndicatorFullWidth(false);

或者在 xml 布局文件中的TabLayout标签设置:

 app:tabIndicatorFullWidth=“false”


但如果想要指示器长度小于字体长度(如上图),API并未提供相关方法,此时就需要我们自定义一个CustomTabLayout 继承 TabLayout,允许开发者自定义选项卡的颜色、字体以及背景等属性。

二、自定义 View

public class CustomTabLayout extends TabLayout {private List<String> titles;private int mSelectColor = getResources().getColor(R.color.white);private int mUnSelectColor = getResources().getColor(R.color.c_80ffffff);public CustomTabLayout(Context context) {this(context,null);}public CustomTabLayout(Context context, AttributeSet attrs) {this(context, attrs,0);}public CustomTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CustomTabLayout);mSelectColor = array.getColor(R.styleable.CustomTabLayout_select_color, mSelectColor);mUnSelectColor = array.getColor(R.styleable.CustomTabLayout_unselect_color, mUnSelectColor);array.recycle();init();}private void init() {titles = new ArrayList<>();this.addOnTabSelectedListener(new OnTabSelectedListener() {@Overridepublic void onTabSelected(Tab tab) {/*** 设置当前选中的Tab为特殊高亮样式。*/if (tab != null && tab.getCustomView() != null) {TextView tab_layout_text = tab.getCustomView().findViewById(R.id.tv_tab_layout);View vIndicator = tab.getCustomView().findViewById(R.id.v_indicator);vIndicator.setVisibility(VISIBLE);vIndicator.setBackgroundColor(mSelectColor);tab_layout_text.setTextColor(mSelectColor);}}@Overridepublic void onTabUnselected(Tab tab) {/*** 重置所有未选中的Tab颜色、字体、背景恢复常态(未选中状态)。*/if (tab != null && tab.getCustomView() != null) {TextView tab_layout_text = tab.getCustomView().findViewById(R.id.tv_tab_layout);View vIndicator = tab.getCustomView().findViewById(R.id.v_indicator);vIndicator.setVisibility(INVISIBLE);tab_layout_text.setTextColor(mUnSelectColor);}}@Overridepublic void onTabReselected(Tab tab) {}});}public void setTitle(List<String> titles) {this.titles = titles;/*** 开始添加切换的Tab。*/for (String title : this.titles) {Tab tab = newTab();tab.setCustomView(R.layout.item_custom_tablayout);if (tab.getCustomView() != null) {TextView text = tab.getCustomView().findViewById(R.id.tv_tab_layout);text.setText(title);text.setTextColor(mUnSelectColor);}this.addTab(tab);}}
}

相关属性

styleable 
    <declare-styleable name="CustomTabLayout"><attr name="select_color" format="color"/><attr name="unselect_color" format="color"/></declare-styleable>
item_custom_tablayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"android:paddingBottom="@dimen/dimen_5"android:gravity="center_horizontal"><TextViewandroid:id="@+id/tv_tab_layout"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textStyle="bold"android:textColor="@color/c_80ffffff"android:textSize="@dimen/textsize_16"/><Viewandroid:id="@+id/v_indicator"android:layout_width="@dimen/dimen_30"android:layout_height="@dimen/dimen_3"android:visibility="invisible"android:layout_marginTop="@dimen/dimen_6"android:background="@color/white"/></LinearLayout>

使用方法

List<String> titles = new ArrayList<>();
titles.add("待签收");
titles.add("已签收");List<Fragment> mFragments = initFragments();
adapter = new ViewPaperAdapter(getSupportFragmentManager(), mFragments, titles);
mViewPager.setAdapter(adapter);mTabLayout.setTitle(titles);//Tablayout自定义view绑定ViewPager
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
mTabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));

总结

如果对你有所帮助的话,不妨 点赞收藏
如果你有什么疑问的话,不妨 评论私信
青山不改,绿水长流 ,有缘江湖再见 ~

http://www.yidumall.com/news/101337.html

相关文章:

  • 通过php获取手机网站访客的手机号码seo网站建设优化什么意思
  • 百度站长收录某网站seo策划方案
  • 网站收录了怎么做排名拓客平台有哪些
  • 公司网站开发费用怎么做账百度推广账户登录首页
  • 网站设计一般会遇到哪些问题网络销售网站
  • sns有哪些著名的网站有哪些30个免费货源网站
  • ps网站轮播图怎么做百度搜索关键词热度
  • 外网购物平台太原seo推广外包
  • 做网站排名收益seo与sem的区别和联系
  • 青岛网站建设定制开发东莞seo建站如何推广
  • 沈阳哪家做网站最好什么是seo和sem
  • 深圳市建网站公万能推广app
  • 河南建设工程造价管理协会网站公众号怎么开通
  • 最好用的网站推广经验营销型网站建设的重要原则
  • 安徽网站建设大全百度快速优化软件排名
  • 做医疗器械网站域名访问网站入口
  • 晚上做羞羞的事情视频网站免费的郑州网络推广服务
  • 建设一个网站思路网店产品seo如何优化
  • 用模板做的网站不好优化找广告商的平台
  • 网站建站公司服务好吗seo推广有哪些公司
  • 网站的结构小广告图片
  • 山西大同网站建设价格seo推广效果怎么样
  • 宁波专业平台网站建设aso优化软件
  • 电商网站图片处理常见网络营销推广方法
  • pc端网站建设联系方式优化网站标题是什么意思
  • 设计类专业排名石家庄seo公司
  • 网页设计的网站网络广告推广服务
  • 做网站如何挣钱十大网络舆情案例
  • 服务器做视频网站长沙seo排名优化公司
  • 找哪些公司做网站产品线上营销有哪些方式