Android中带意图的自定义选项卡视图

Android中带意图的自定义选项卡视图,android,customization,tabview,Android,Customization,Tabview,我想创建如下图所示的选项卡视图。我试过了,但看不清楚 这是我的密码。。这并不是我想要的确切视图。那么,我如何定制它呢 public class BandInfo extends TabActivity implements OnTabChangeListener { TabHost tabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceS

我想创建如下图所示的选项卡视图。我试过了,但看不清楚

这是我的密码。。这并不是我想要的确切视图。那么,我如何定制它呢

public class BandInfo extends TabActivity implements OnTabChangeListener {

TabHost tabHost;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.band_info);

    tabHost = getTabHost();

    tabHost.getTabWidget().setBackgroundResource(R.drawable.footerbar);


    // Tab for Bio
    TabSpec bioSpec = tabHost.newTabSpec("Bio");
    // Setting Title for Tab
    bioSpec.setIndicator("Bio");
    Intent bioIntent = new Intent(this,Bio.class);
    bioSpec.setContent(bioIntent);

    // Tab for Upcoing Shows
    TabSpec upcomingShowSpec = tabHost.newTabSpec("Upcoming Shows");
    upcomingShowSpec.setIndicator("Upcoming Shows");
    Intent upcomingShowIntent = new Intent(this, UpcomingShow.class);
    upcomingShowSpec.setContent(upcomingShowIntent);

    // Tab for Band Members
    TabSpec bandMemberSpec = tabHost.newTabSpec("Band Members");
    bandMemberSpec.setIndicator("Band Members");
    Intent bandMemberIntent = new Intent(this, BandMembers.class);
    bandMemberSpec.setContent(bandMemberIntent);

    // Adding all TabSpec to TabHost
    tabHost.addTab(bioSpec); // Adding Bio Tab
    tabHost.addTab(upcomingShowSpec); // Adding Upcoming Show Tab
    tabHost.addTab(bandMemberSpec); // Adding Band Members Tab

    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
    {
        tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.footerbar);
    }
    tabHost.getTabWidget().setDividerDrawable(R.drawable.footer_saprater);
}
@Override
public void onTabChanged(String tabId) {
    // TODO Auto-generated method stub
    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
    {
        tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.footerbar);
    }
    tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(R.drawable.bandmember_active);
}
公共类BandInfo扩展TabActivity实现OnTabChangeListener{
TabHost-TabHost;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.band_信息);
tabHost=getTabHost();
tabHost.getTabWidget().setBackgroundResource(R.drawable.footerbar);
//生物标签
TabSpec bioSpec=tabHost.newTabSpec(“Bio”);
//设置选项卡的标题
bioSpec.setIndicator(“Bio”);
Intent bioIntent=新Intent(这个,Bio.class);
bioSpec.setContent(bioIntent);
//用于升级显示的选项卡
TabSpec upcomingShowSpec=tabHost.newTabSpec(“即将到来的节目”);
升级ShowSpec.setIndicator(“即将到来的节目”);
Intent upcomingShowIntent=新的Intent(这个,UpcomingShow.class);
升级ShowSpec.setContent(升级ShowIntent);
//用于乐队成员的选项卡
TabSpec bandMemberSpec=tabHost.newTabSpec(“带成员”);
bandMemberSpec.setIndicator(“波段成员”);
Intent bandMemberIntent=新的Intent(这是BandMembers.class);
bandMemberSpec.setContent(bandMemberIntent);
//将所有TabSpec添加到TabHost
tabHost.addTab(bioSpec);//添加Bio选项卡
tabHost.addTab(upcomingShowSpec);//添加即将到来的Show选项卡
tabHost.addTab(bandMemberSpec);//添加乐队成员选项卡

因为(inti=0;iHeyy我找到了这个。试试这个。你一定会成功的

对于设置宽度

tabHost.getTabWidget().getChildAt(0.getLayoutParams().width=(int)30;


同时检查此链接:和

您做了什么吗?是的,我尝试了,但选项卡的标题名称未设置在中间..您好…您仍然无法解决此问题?请将文本视图与背景图像一起使用,而不是使用TabView。请显示您使用此代码获得的图像。以便其他人能够理解您得到的结果使用此代码和您试图实现的目标。