Bal*_*yto 6 compatibility tabs android
我在这里阅读了一些文章 如何创建像这样的Android标签(截图)?
后来在评论中有sherlock lib,它为具有Android 2.2的设备带来4.0外观.
我的问题是,我正试图让"丑陋":)旧外观在新设备上工作.
像图像上的东西:

所以我想要Tabs,没有Action栏,只有5个盒子,图片和文本最好来自字符串,因为它需要本地化.
所以,我正在使用,并且在tablayout.xml中我设置了title(来自字符串),并以编程方式将图像添加到我的资源中的某个选项卡.
th.setup();
TabSpec specs = th.newTabSpec("tag1");
//specs.setContent(new Intent(this,MyAppTab.class));
specs.setContent(R.id.tab1);
specs.setIndicator(getResources().getString(R.string.tab_myapp_title), getResources().getDrawable(R.drawable.ic_tab1_active));
Run Code Online (Sandbox Code Playgroud)
现在发生了什么,就是在我的Android 2.2上.电话,它看起来很丑,但有图像,有点我想要的东西,在妻子的4.0上,我看到只有文字的花哨的新标签.
如何在所有Android版本中添加标签图像?
TNX
您可以通过此方法使用自定义视图作为选项卡指示器。
View yourView = inflater.inflate(R.layout.my_tab_indicator, null);((ImageView) yourView.findViewById(R.id.tab_indicator_icon)).setBitmapRessource(...)((TextView) yourView.findViewById(R.id.tab_indicator_title)).setText(...)tabSpec.setIndicator(yourView);| 归档时间: |
|
| 查看次数: |
1986 次 |
| 最近记录: |