Android Forums

Go Back   These FORUMS ARE DISABLED!! OUR NEW FORUMS ARE AT http://androidforum.com/ > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
 
 
LinkBack Thread Tools Display Modes
Old 07-28-2010, 04: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
Old 07-29-2010, 08: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
Old 07-29-2010, 10: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
 

Thread Tools
Display Modes



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


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

All times are GMT -6. The time now is 08:29 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) 2012 TalkAndroid.com. All rights reserved.