사용자 정의 TAB 설치 인터페이스 아래쪽
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->package com.TabTest2;
import java.lang.reflect.Field;
import android.app.Activity;
import android.os.Build;
import android.R;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.TabHost.OnTabChangeListener;
public class TabTest2 extends Activity {
    public void onCreate(Bundle icicle) {   
        super.onCreate(icicle);   
        setContentView(com.TabTest2.R.layout.main);   
        final TabHost tabs=(TabHost)findViewById(com.TabTest2.R.id.tabhost);   
        final TabWidget tabWidget=(TabWidget) findViewById(R.id.tabs);
        int width =45;
        int height =48;
        Field mBottomLeftStrip;
        Field mBottomRightStrip;
        tabs.setup();   
           
          
           
        tabs.addTab(tabs.newTabSpec("first tab")
                .setIndicator("news",getResources().getDrawable(com.TabTest2.R.drawable.c))
                .setContent(com.TabTest2.R.id.tab1));
        tabs.addTab(tabs.newTabSpec("second tab")
                .setIndicator("help",getResources().getDrawable(com.TabTest2.R.drawable.e))
                .setContent(com.TabTest2.R.id.tab2));
        tabs.addTab(tabs.newTabSpec("third tab")
                .setIndicator("setting",getResources().getDrawable(com.TabTest2.R.drawable.efg))
                .setContent(com.TabTest2.R.id.tab2));
           
        tabs.setCurrentTab(0);  
        
        
        for (int i =0; i <tabWidget.getChildCount(); i++) {
            /**
             * 设置高度、宽度,不过宽度由于设置为fill_parent,在此对它没效果
             */
            tabWidget.getChildAt(i).getLayoutParams().height = height;
            tabWidget.getChildAt(i).getLayoutParams().width = width;
         /**
          * 设置tab中标题文字的颜色,不然默认为黑色
          */
          final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
          tv.setTextColor(this.getResources().getColorStateList(android.R.color.white));
            /**
             * 此方法是为了去掉系统默认的色白的底角
             *
             * 在 TabWidget中mBottomLeftStrip、mBottomRightStrip
             * 都是私有变量,但是我们可以通过反射来获取
             *
             * 由于还不知道Android 2.2的接口是怎么样的,现在先加个判断好一些
             */
      if (Float.valueOf(Build.VERSION.RELEASE) <= 2.1) {
               try {
                  mBottomLeftStrip = tabWidget.getClass().getDeclaredField ("mBottomLeftStrip");
                  mBottomRightStrip = tabWidget.getClass().getDeclaredField ("mBottomRightStrip");
                  if(!mBottomLeftStrip.isAccessible()) {
                    mBottomLeftStrip.setAccessible(true);
                  }
                  if(!mBottomRightStrip.isAccessible()){
                    mBottomRightStrip.setAccessible(true);
                  }
                 mBottomLeftStrip.set(tabWidget, getResources().getDrawable (com.TabTest2.R.drawable.linee));
                 mBottomRightStrip.set(tabWidget, getResources().getDrawable (com.TabTest2.R.drawable.linee));
               } catch (Exception e) {
                 e.printStackTrace();
               }
         } else {
        
         }
        View vvv = tabWidget.getChildAt(i);
  if(tabs.getCurrentTab()==i){
          vvv.setBackgroundDrawable(getResources().getDrawable(com.TabTest2.R.drawable.shine));
  }
  else {
          vvv.setBackgroundDrawable(getResources().getDrawable(com.TabTest2.R.drawable.seven));
  }
        }
        
        /**
         * 当点击tab选项卡的时候,更改当前的背景
         */
        tabs.setOnTabChangedListener(new OnTabChangeListener(){
   @Override
   public void onTabChanged(String tabId) {
    // TODO Auto-generated method stub
    for (int i =0; i < tabWidget.getChildCount(); i++) {
     View vvv = tabWidget.getChildAt(i);
     if(tabs.getCurrentTab()==i){
             vvv.setBackgroundDrawable(getResources().getDrawable(com.TabTest2.R.drawable.shine));
     }
     else {
             vvv.setBackgroundDrawable(getResources().getDrawable(com.TabTest2.R.drawable.seven));
     }
    }
   }});
        
    }   
}
 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    android:orientation="vertical"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent">  
    <TabHost  
        android:id="@+id/tabhost"  
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent">  
        <FrameLayout  
            android:id="@android:id/tabcontent"  
            android:layout_width="fill_parent"  
            android:layout_height="fill_parent"  
            android:paddingBottom="62px">  
            <AnalogClock  
                android:id="@+id/tab1"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:layout_centerHorizontal="true" />  
            <Button  
                android:id="@+id/tab2"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:text="A semi-random button" />  
        </FrameLayout>  
        <RelativeLayout  
            android:layout_width="fill_parent"  
            android:layout_height="fill_parent">  
            <TabWidget  
                android:id="@android:id/tabs"  
                android:layout_alignParentBottom="true"  
                android:layout_width="fill_parent"  
                android:layout_height="60px" />  
        </RelativeLayout>  
    </TabHost>  
</LinearLayout>
 
http://www.cnblogs.com/tt_mc/archive/2010/05/26/1744502.html
                
                    
        
    
    
    
    
    
                
                
                
                
                
                
                    
                        
                            
                            
                                
                                    
                                    이 내용에 흥미가 있습니까?
                                
                            
                            
                            
                            현재 기사가 여러분의 문제를 해결하지 못하는 경우  AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
                            
                                
                                Kotlin의 기초 - 2부
                            
                            지난 글에서는 Kotlin이 무엇인지, Kotlin의 특징, Kotlin에서 변수 및 데이터 유형을 선언하는 방법과 같은 Kotlin의 기본 개념에 대해 배웠습니다.
유형 변환은 데이터 변수의 한 유형을 다른 데이터...
                            
                            
                            
                            
                            텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.