我正在尝试使用带有SherlockFragmentActivity的TabsAdapter添加自定义菜单。
目前我有4个标签的标签菜单, 我想添加一个覆盖整个菜单和标签
的自定义图像(标记为绿色圆圈)知道如何做到这一点?
答案 0 :(得分:1)
我找到了解决方案:
向TabsAdapter添加4个标签 将布局边距添加到第二个选项卡:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int heigth = mTabHost.getTabWidget().getChildAt(0).getLayoutParams().height;
mTabHost.getTabWidget().getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));
mTabHost.getTabWidget().getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));
View currentView = mTabHost.getTabWidget().getChildAt(1);
LinearLayout.LayoutParams currentLayout = (LinearLayout.LayoutParams) currentView.getLayoutParams();
currentLayout.setMargins(0, 0, width / 5, 0);
mTabHost.getTabWidget().getChildAt(2).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));
mTabHost.getTabWidget().getChildAt(3).setLayoutParams(new LinearLayout.LayoutParams((width / 5), heigth));