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

dede音乐网站源码wordpress侧边栏图和标题

dede音乐网站源码,wordpress侧边栏图和标题,wordpress 获取页面,互联网舆情监测系统前言 原生 TabLayout 的指示器长度是充满整个屏幕的#xff0c;但在实际开发中 UI 会设计成 指示器的长度等于或者小于标题字体长度#xff0c;如图 如果设置成跟字体长度一样即使用 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 ListString 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(ListString 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 nameCustomTabLayoutattr nameselect_color formatcolor/attr nameunselect_color formatcolor//declare-styleable item_custom_tablayout ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:orientationverticalandroid:paddingBottomdimen/dimen_5android:gravitycenter_horizontalTextViewandroid:idid/tv_tab_layoutandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textStyleboldandroid:textColorcolor/c_80ffffffandroid:textSizedimen/textsize_16/Viewandroid:idid/v_indicatorandroid:layout_widthdimen/dimen_30android:layout_heightdimen/dimen_3android:visibilityinvisibleandroid:layout_marginTopdimen/dimen_6android:backgroundcolor/white//LinearLayout 使用方法 ListString titles new ArrayList(); titles.add(待签收); titles.add(已签收);ListFragment 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.hkea.cn/news/14568623/

相关文章:

  • 网站域名被注销重新备案怎么做硬件产品开发流程图
  • asp网站开发后如何交付设计感 网站
  • 全屏网站 图片优化网站建设规划怎么写
  • 网站建设+公司网站屏蔽收录
  • 医院网站建设的理由烟台网站网站建设
  • gif图标网站京东联盟网站推广位怎么做
  • 站外推广策划书个人网站制作步骤
  • 做网站要服务器和什么张掖seo
  • 查询网站名有没有收录杭州市公共资源交易中心
  • 关于做网站公司周年大促销cms系统和网站后台系统
  • 深圳模板网站建设多语言网站多域名推广
  • wordpress自助建站便捷网站建设费用
  • 温州建设网站公司哪家好定制开发板
  • 南宁做网站的公司透明水印logo在线制作
  • 网站引导动画怎么做的微信公众号登录平台登录官网
  • 常见网站模式公司注册地址在外地却在本地经营
  • 东莞定制建站网站推广公司徐州网站建设公司哪家好
  • 鲜花网站模板下载网站权重为零
  • 网站建设服务市场erp系统软件有哪些
  • 网站建设的架构设计网站开发市场规模
  • 网站建设温州视频网站点击链接怎么做的
  • 买手表去哪个网站买是正品的网站如何做水晶按钮
  • 网站架构软件网站上线多久才能百度
  • 建立公司企业网站企业网站策划流程
  • 数码类网站名称数据服务网站开发
  • 长沙网站设计服务重庆手机网站推广定做
  • 有用模板网官网seo快速排名软件
  • 建设银行信用卡网站显示余额中英文的网站怎么建设
  • 关于校园网站建设的建议网站 关键词库
  • 天津电子商务网站建设公司网推资源网站