修改TabHost导航高度和背景颜色,tabhost背景颜色,主要是android使用
分享于 点击 21307 次 点评:133
修改TabHost导航高度和背景颜色,tabhost背景颜色,主要是android使用
主要是android使用TabHost布局时。设置tabhost的导航条高度,及背景颜色
private TabWidget tabWidget; private TabHost tabHost; tabHost = getTabHost();//自己添加//TabHost.TabSpec tabSpec01 = tabHost.newTabSpec("one");//tabSpec01.setIndicator("个人信息", null); // Intent intent01 = new Intent(MyXiTuanTestActivity.this, // MyInfoActivity.class);// tabSpec01.setContent(intent01);// tabHost.addTab(tabSpec01); tabWidget = tabHost.getTabWidget();for (int i = 0; i < tabWidget.getChildCount(); i++) { tabWidget.getChildAt(i).getLayoutParams().height = 45; tabWidget.getChildAt(i).getLayoutParams().width = 65; TextView tv = (TextView) tabWidget.getChildAt(i).findViewById( android.R.id.title); tv.setTextSize(15); tv.setTextColor(this.getResources().getColorStateList( android.R.color.white)); }// 改变头部的背景色 // Object v = tabWidget.getChildAt(i); // if (v instanceof RelativeLayout) { // RelativeLayout vvv = (RelativeLayout) v; // if (tabHost.getCurrentTab() == i) { // vvv.setBackgroundDrawable(getResources().getDrawable( // R.drawable.onclick_shape)); // } else { // vvv.setBackgroundDrawable(getResources().getDrawable( // R.drawable.green_shape)); // } // // }//该片段来自于http://byrx.net
用户点评