Android Forums

Go Back   Android Forums > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
Reply
 
LinkBack Thread Tools Display Modes
Old 07-28-2010, 05:44 AM   #1
Android Developer
 
Join Date: Jul 2010
Location: Hyderabad, India
Posts: 2
Friends: 0
View deep007.mm's Profile   View deep007.mm's Photo Album   View deep007.mm's Blog   View Social Groups
Hi Everybody,

I am using TabWidget. It comes with the default grey background color. Is it possible to change this? If it is then please tell me how can I do this??

Thanks

Deepak
deep007.mm is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Reply With Quote
Old 07-29-2010, 09:31 AM   #2
New Member
 
Join Date: Jul 2010
Posts: 1
Friends: 0
View mapeters's Profile   View mapeters's Photo Album   View mapeters's Blog   View Social Groups
The following shows how to change the color and the height of the standard Android tabs.

In TabActivity.onCreate():

final TabHost tabHost = getTabHost();

tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener()
@Override
public void onTabChanged(String tabId) {
setTabColors(tabHost);
}
});

...

// This tab activity is always launched via an intent which
// passes the tag of the tab to start on in a String extra
// with key "tab_name". Set the current tab before initializing
// the colors.
tabHost.setCurrentTabByTag(getIntent().getStringEx tra("tab_name"));
setTabColors(tabHost);

As a method in your TabActivity:

private void setTabColors(final TabHost tabHost) {
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
tabHost.getTabWidget().getChildAt(i).getLayoutPara ms().height = 40;
tabHost.getTabWidget().getChildAt(i).setBackground Color(Color.LTGRAY);
}

tabHost.getTabWidget().getChildAt(tabHost.getCurre ntTab())
.setBackgroundColor(Color.parseColor(Color.RED));
}

Quote:
Originally Posted by deep007.mm View Post
Hi Everybody,

I am using TabWidget. It comes with the default grey background color. Is it possible to change this? If it is then please tell me how can I do this??

Thanks

Deepak
mapeters is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Reply With Quote
Old 07-29-2010, 11:47 PM   #3
Android Developer
 
Join Date: Jul 2010
Location: Hyderabad, India
Posts: 2
Friends: 0
View deep007.mm's Profile   View deep007.mm's Photo Album   View deep007.mm's Blog   View Social Groups
Hi,
Thanks for the response.

You are telling method to change the tab on any events. But I want to change the background colors of Tab widget without on any events.

Thanks
Deepak
deep007.mm is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Reply With Quote
Reply

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the color of the elements in a listview daneves Android Development, Answers, Tutorials, and Code Snippets 0 06-07-2010 09:37 PM
How Do You Change the Selected EditText Field Color? jon21569 Android Development, Answers, Tutorials, and Code Snippets 3 01-26-2010 06:51 AM
Does Skype run in the background and look for calls on Android gnagy Android Games And Applications 1 09-19-2009 01:10 PM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 12:11 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2008 TalkAndroid.com. All rights reserved.