2017-01-03 3 views
-1

に個々のタブにフィット画像を設定するには、この私のコード私は2つのタブ を持っている私のtabhostのタブ にフィットでなければならない画像を設定する方法をtabhost

tab =(TabHost) findViewById(R.id.tabhost); 
tab.setup(); 
TabHost.TabSpec spec = tab.newTabSpec("tag1"); 
spec.setIndicator("",getResources().getDrawable(R.drawable.loginpic)); 
spec.setContent(R.id.tab1); 
tab.addTab(spec); 

spec = tab.newTabSpec("tag2"); 
spec.setIndicator("",getResources().getDrawable(R.drawable.signuppic)); 
spec.setContent(R.id.tab2); 
tab.addTab(spec); 

ある画像は小さく、完全なタブを埋めていない

どうすればいいですか?

答えて

0

これを試してみて、

Drawable loginpic= getResources().getDrawable(R.drawable.loginpic); 
StateListDrawable selector = new StateListDrawable(); 
selector.addState(new int[0], selectedIcon); 
spec.setIndicator("Tab 1", selector); 
+0

同じ結果:/ –

関連する問題