SlidingTabLayout
【Android】SlidingTabLayout实现标题栏,教你制作title标题 简单易学。
Install / Use
/learn @dmcxiaobing/SlidingTabLayoutREADME
SlidingTabLayout
【Android】SlidingTabLayout实现标题栏,教你制作title标题 简单易学。
作者: 程序员小冰
QQ986945193 微博:http://weibo.com/mcxiaobing
首先先给大家看一下效果图:
介绍:本小demo里面引用了两个google的官方类,SlidingTabLayout和SlidingTabStrip,
我们将它烤进我们的项目中引用即可,具体请看详细代码。特别说明,本项目对slidingTablayout
的源代码进行了修改,如果你是从别处下载的,看到的效果是不一样的,当然标题不是剧中的,
如果想要居中,可以设置代码:
在Android SlidingTabLayout源代码中有一个方法:
private void populateTabStrip();
我们添加一些代码即可:
LinearLayout.LayoutParams layoutParams= new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0f);
tabView.setLayoutParams(layoutParams);
放在: tabTitleView.setText(adapter.getPageTitle(i));
tabView.setOnClickListener(tabClickListener);
//添加在此位置
LinearLayout.LayoutParams layoutParams= new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0f);
tabView.setLayoutParams(layoutParams);
//
mTabStrip.addView(tabView);
```
如果要修改 选中效果 的颜色,或者加上选中颜色过度效果,或者 分割线的颜色,可以为 SlidingTabLayout设置属性
tab.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
@Override
public int getIndicatorColor(int position) {
return colors[position];//每个选项卡所对应的颜色
}
//分割线颜色
@Override
public int getDividerColor(int position) {
return 0x00FFFFFF;
}
});
如果对您有帮助,欢迎star,fork。。。
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
