选中标签后更改文字大小

时间:2014-03-19 23:04:33

标签: android textview selecteditem selected

当tabwidget被选中时,是否可以更改textview中textview的文本大小?

1 个答案:

答案 0 :(得分:1)

是的,这是一个例子:

public class MainActivity extends TabActivity {

static TabHost mytabs;


mytabs = getTabHost();

    mytabs.setOnTabChangedListener(new OnTabChangeListener() {
        @Override
        public void onTabChanged(String arg0) {         
            Log.i("TAG", "Im currently in tab with index: " + mytabs.getCurrentTab());
            TabWidget tw = (TabWidget)tabHost.findViewById(android.R.id.tabs);
            View tabView = tw.getChildTabViewAt(mytabs.getCurrentTab());
            TextView tv = (TextView)tabView.findViewById(android.R.id.title);
            // Changing textSize.
            tv.setTextSize(20);
        }       
    });