在Android的自定义选项卡 [英] Custom tabs in android

查看:136
本文介绍了在Android的自定义选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个真的很难理解如何使用自定义选项卡中的机器人。我不想只能够设置文本和东西。我怎样才能改变大小,图像,和所有。

I'm having a really hard time understanding how to use custom tabs in android. I don't want to just be able to set the text and stuff. How can I change the size, and the image, and all that.

我GOOGLE了,我找不到任何有意义

I've googled and I can't find anything that makes sense

推荐答案

您可以创建/ RES /布局XML布局文件。然后,你需要抬高布局查看和设置指标。我用这个code在我的项目:

You can create XML layout file in /res/layout. Then you need inflate layout in View and set indicator. I use this code in my projects:

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);
}

这篇关于在Android的自定义选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆