Today, I mainly studied Android tabwidget, but at first I was not satisfied with the adjustment of height and text center.
If the image display effect is not added, it may not feel good.
It feels so bad. Then process the tabwidget.
The process is as follows:
Tabwidget = tabhost. gettabwidget (); For (INT I = 0; I <tabwidget. getchildcount (); I ++) {view child = tabwidget. getchildat (I); Final textview TV = (textview) child. findviewbyid (Android. r. id. title); relativelayout. layoutparams Params = (relativelayout. layoutparams) TV. getlayoutparams (); Params. addrule (relativelayout. align_parent_bottom, 0); // cancel text baseline align_parent_bottom. addrule (relativelayout. center_in_parent, relativelayout. true); // set the center alignment of the text}
However, this is highly uncoordinated, and you need to adjust the height and then change the code.
Tabwidget = tabhost. gettabwidget (); For (INT I = 0; I <tabwidget. getchildcount (); I ++) {view child = tabwidget. getchildat (I); Final textview TV = (textview) child. findviewbyid (Android. r. id. title); relativelayout. layoutparams Params = (relativelayout. layoutparams) TV. getlayoutparams (); Params. addrule (relativelayout. align_parent_bottom, 0); // cancel text baseline align_parent_bottom. addrule (relativelayout. center_in_parent, relativelayout. true); // set the text center to align with child. getlayoutparams (). height = 30; // final imageview IV = (imageview) Child //. findviewbyid (Android. r. id. icon); // IV. getlayoutparams (). height = 0 ;}
View the display result again
In the end, we can achieve what we want!