It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center




已关闭8年。




我很难理解如何在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);
}

10-07 19:20
查看更多