题
我很难理解如何在Android中使用自定义标签。我不想只设置文字和内容。我如何更改大小,图像等。
我已经搜索过,我找不到任何有意义的东西
解决方案
您可以在 /res /layout中创建XML布局文件。然后,您需要在视图和设置指示器中充气布局。我在项目中使用此代码:
private static View prepareTabView(Context context, int textId, int drawable) {
View view = LayoutInflater.from(context).inflate(R.layout.tab_layout, null);
// setting text and image
// ...
// Write your own code here
return view;
}
public static void addTab(TabHost host, int title, String tag, int drawable, int layout) {
TabHost.TabSpec spec = host.newTabSpec(tag);
spec.setContent(layout);
View view = prepareTabView(host.getContext(), title, drawable);
spec.setIndicator(view);
host.addTab(spec);
}
不隶属于 StackOverflow