我有 6 个选项卡,当我单击任何选项卡时,它应该将重力设置为中心。我怎样才能做到这一点..?
这是代码,但它没有效果..请帮助..
Calendar c = Calendar.getInstance();
int day = c.get(Calendar.DAY_OF_WEEK);
try{
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
int scrollX = (th.getTabWidget().getChildAt(day-2).getLeft() - (screenWidth/2))
+(th.getTabWidget().getChildAt(day-2).getWidth()/2);
hsv.scrollTo(scrollX,0);
//hsv is horizontalScrollView from the xml file
//th is the tabhost
th.setCurrentTab(day-2);
}catch(Exception e){
th.setCurrentTab(2);
}
请告诉我可能出了什么问题..