android TabHost icon of 48215; 48 and text overlay solution
- 2020-05-09 19:14:57
- OfStack
In the process of development, sometimes the icon is a little bit larger, such as 48×48, the text will be superimposed with the icon, the solution is as follows:
TabWidget tw = tabHost.getTabWidget();
for (int i = 0; i < tw.getChildCount(); i++)
{
TextView tv=(TextView)tw.getChildAt(i).findViewById(android.R.id.title);
ImageView iv=(ImageView)tw.getChildAt(i).findViewById(android.R.id.icon);
iv.setPadding(0, -8, 0, 0);
tv.setPadding(0, 0, 0, -2);
tv.setTextSize(12); }