Tab layout not displaying as I want
I am using custo开发者_运维知识库m background for my Tab layout, but it displaying something different. As
but I want as
and my code is as
for(int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#0079AD"));
((TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title)).setTextColor(Color.parseColor("#8CD7F2"));
}
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#009ED6"));
how can I solve this?
For getting effect as I wan't I am using drawable image as follow and I am getting result as I wan't almost same as your.
ImageView view1;
TabHost tabHost;
tabHost = getTabHost()
TabHost.TabSpec spec;
Intent intent;
view1 = new ImageView(this);
view1.setOnTouchListener(view1Touch);//for identifying touch newly added.
view1.setBackgroundResource(R.drawable.tab_image);
intent = new Intent().setClass(this, AnohterActivity.class);
spec = tabHost.newTabSpec(TAG_1).setIndicator(view1).setContent(
intent);
tabHost.addTab(spec);
=======================
OnTouchListener view1Touch = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
v.setBackgroundResource(R.drawable.tab_focus);
}
}
and TabChangeListener you might be already added.
精彩评论