I set my minSdkVersion to 8 and targetSdkVersion also to 8, everything seems to be okay except for one thing. My tab bar (custom tab bar) graphics have shrunk to about half their size. All the other graphics in the app seem fine. It’s probably worth noting that the tab bar graphics are the only graphics I size programmatically upon app launch. Here is a snippet from my setUpTabs() method:
public void setUpTabs()
{
//Tab setup
TabHost mTabHost = getTabHost();
ListView pastTripsListView=(ListView)findViewById(R.id.pastTrips);
//ListView settingsListView=(ListView)findViewById(R.id.settings);
ListView upcomingTripsListView=(ListView)findViewById(R.id.upcomingTrips);
pastTripsListView.setAdapter(pastTripsAdapter);
pastTripsListView.setOnItemClickListener(pastTripsAdapter);
upcomingTripsListView.setAdapter(upcomingTripsAdapter);
upcomingTripsListView.setOnItemClickListener(upcomingTripsAdapter);
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("").setContent(R.id.pastTrips));
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("").setContent(R.id.settings));
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("").setContent(R.id.upcomingTrips));
mTabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 49;
mTabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 49;
mTabHost.getTabWidget().getChildAt(2).getLayoutParams().height = 49;
RelativeLayout tabLayoutLeft = (RelativeLayout) mTabHost.getTabWidget().getChildAt(0);
tabLayoutLeft.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_indicator_left));
RelativeLayout tabLayoutCenter = (RelativeLayout) mTabHost.getTabWidget().getChildAt(1);
tabLayoutCenter.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_indicator_center));
RelativeLayout tabLayoutRight = (RelativeLayout) mTabHost.getTabWidget().getChildAt(2);
tabLayoutRight.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_indicator_right));
mTabHost.setCurrentTab(2);
//End Tab setup
}
Now, the 49 I’m setting for the height is in pixels or dip??? Could this be what’s causing the problem? Can I just set these tabs up in the xml file instead?
Also when I hover over the word “height” the intellisense tells me the following:
Information about how tall the view wants to be. Can be one of the constants FILL_PARENT (replaced by MATCH_PARENT , in API Level 8) or WRAP_CONTENT. or an exact size.
When I try MATCH_PARENT it says it can’t be resolved. Where can I get this?
Thanks a lot.
I don’t this you should do this:
And expect it to stick. AFAIK You should be doing:
Besides, you are setting the height to fixed pixels. You should always use
dipif you want your widget to remain the same height in multiple screen resolutions. The conversion from dip to pixels is easy: