2011-04-08 8 views
0

내 탭 레이아웃에 사용자 정의 배경을 사용하고 있지만 다른 것을 표시하고 있습니다. 하지만 enter image description here원하는대로 탭 레이아웃이 표시되지 않습니다.

으로 나는

enter image description here

로 원하는 내 코드는 내가이 문제를 해결하는 방법을

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")); 

같다?

답변

1

내가 얻지 못하는만큼 효과를 얻으려면 다음과 같이 드로어 블 이미지를 사용하고 있으며 나는 당신과 거의 같은 결과를 얻지 못하고 있습니다.

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); 
     } 

}

당신은 이미 추가 될 수 TabChangeListener.

+0

하지만이 방법을 사용하면 선택기를 구현할 수 있습니까? 제발 나를 안내 해줘. –

관련 문제