0

SherlockActionBar를 사용하여 API> = 2.2에서 내 탭을 볼 수 있습니다. 필요한 것은 탭의 사용자 정의 스타일 인 배경, 텍스트 및 텍스트 색상입니다. 난 내 2.3 API 전화를 테스트 할 때 - 내가 원하는대로 탭을 찾습니다 https://dl.dropboxusercontent.com/u/4277073/device-2013-06-20-105544.pngSherlockActionBar 탭 호스트의 탭 사이의 흰색 틈

을 내가 내가 탭 사이에 이상한 흰색 격차를 얻고있다 삼성 S3에서 테스트 그러나 때 https://dl.dropboxusercontent.com/u/4277073/tabs.png

당신은 알고 계십니까 왜 그렇게 생각하니? 또는 내 응용 프로그램에서 액션 바를 사용하지 마십시오. mb는 어떻게 든 탭 탐색을 다르게 구현해야합니까? 방법? 여기

여기
<?xml version="1.0" encoding="utf-8"?> 
<TabHost 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#EFEFEF"> 

<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="wrap_content" /> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@android:id/tabs"> 

     <FrameLayout 
      android:id="@+id/tab_1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 

     <FrameLayout 
      android:id="@+id/tab_2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
     <FrameLayout 
      android:id="@+id/tab_3" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
    </FrameLayout> 
</RelativeLayout> 
</TabHost> 

내 탭 XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="@dimen/tab_height" 
android:gravity="center" 
android:padding="@dimen/tab_padding" 
android:layout_weight="1" 
android:layout_width="0dp" 
android:background="@drawable/tab_selector"> 

<TextView 
    android:id="@+id/text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="@dimen/text_small" 
    android:textStyle="bold" 
    android:textColor="@drawable/tab_text_selector" /> 
</LinearLayout> 

내 tabhost 조각입니다 그리고 이것은 내가합니다 (setTabColor에 탭 모양을 변경 내 TabsFragment) 방법 :

public class TabsFragment extends SherlockFragment implements OnTabChangeListener { 

private static final String TAG = "FragmentTabs"; 
public static final String TAB_FIND = "FIND FOOD"; 
public static final String TAB_MAP = "MAP"; 
public static final String TAB_EVENTS = "EVENTS"; 

private View mRoot; 
private TabHost mTabHost; 
private int mCurrentTab; 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 
    mRoot = inflater.inflate(R.layout.tabs_fragment, null); 
    setHasOptionsMenu(true); 
    mTabHost = (TabHost) mRoot.findViewById(android.R.id.tabhost); 
    setupTabs(); 
    return mRoot; 
} 

@Override 
public void onActivityCreated(Bundle savedInstanceState) { 
    super.onActivityCreated(savedInstanceState); 
    setRetainInstance(true); 

    mTabHost.setOnTabChangedListener(this); 
    mTabHost.setCurrentTab(mCurrentTab); 
    // manually start loading stuff in the first tab 
    updateTab(TAB_FIND, R.id.tab_1); 
} 

private void setupTabs() { 
    mTabHost.setup(); // important! 
    mTabHost.addTab(newTab(TAB_FIND, R.string.tab_find, R.id.tab_1)); 
    mTabHost.addTab(newTab(TAB_MAP, R.string.tab_map, R.id.tab_2)); 
    mTabHost.addTab(newTab(TAB_EVENTS, R.string.tab_events, R.id.tab_3)); 
    setTabColor(mTabHost); 
} 

private TabSpec newTab(String tag, int labelId, int tabContentId) { 
    View indicator = LayoutInflater.from(getActivity()).inflate(
      R.layout.tab, 
      (ViewGroup) mRoot.findViewById(android.R.id.tabs), false); 
    ((TextView) indicator.findViewById(R.id.text)).setText(labelId);have 
    ((TextView) indicator.findViewById(R.id.text)).setTextSize(16); 

    TabSpec tabSpec = mTabHost.newTabSpec(tag); 
    tabSpec.setIndicator(indicator); 
    tabSpec.setContent(tabContentId); 
    return tabSpec; 
} 

@Override 
public void onTabChanged(String tabId) { 
    if (TAB_FIND.equals(tabId)) { 
     updateTab(tabId, R.id.tab_1); 
     mCurrentTab = 0; 

    } 
    if (TAB_MAP.equals(tabId)) { 
     updateTab(tabId, R.id.tab_2); 
     mCurrentTab = 1; 

    } 
    if (TAB_EVENTS.equals(tabId)) { 
     updateTab(tabId, R.id.tab_3); 
     mCurrentTab = 1; 

    } 

    setTabColor(mTabHost); 
    return; 
} 

public void setTabColor(TabHost tabhost) { 
    int color ; 
    TextView tv; 


    for(int i=0;i<tabhost.getTabWidget().getChildCount();i++) 
    { 
     color = getSherlockActivity().getResources().getColor(R.color.grey_tab_light); 
     tabhost.getTabWidget().getChildAt(i).setBackgroundColor(color); //unselected 
     View v = tabhost.getTabWidget().getChildAt(i); 
     tv = ((TextView) v.findViewById(R.id.text)); 
     tv.setTextColor(Color.WHITE); 

    } 
    color = getSherlockActivity().getResources().getColor(R.color.grey_tab_dark); 
    tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(color); // selected 
    color = getSherlockActivity().getResources().getColor(R.color.orange_bright); 
    View v = tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()); 
    tv = ((TextView) v.findViewById(R.id.text)); 
    tv.setTextColor(color); 
} 

private void updateTab(String tabId, int placeholder) { 
    FragmentManager fm = getFragmentManager(); 

    if (TAB_FIND.equals(tabId)) { 
     if (fm.findFragmentByTag(tabId) == null) { 
      fm.beginTransaction().replace(placeholder, new FindFoodFragment(), tabId).commit(); 
     } 
    } 
    if (TAB_MAP.equals(tabId)) { 
     if (fm.findFragmentByTag(tabId) == null) { 
      fm.beginTransaction().replace(placeholder, new MapFragment(), tabId).commit(); 
     } 
    } 
    if (TAB_EVENTS.equals(tabId)) { 
     if (fm.findFragmentByTag(tabId) == null) { 

      fm.beginTransaction().replace(placeholder, new EventsFragment(), tabId).commit(); 

     } 
    } 
} 

} 

감사합니다.

답변

0

여전히 큰 해상도 화면에서 왜 문제인지 나에게 이상합니다.

은 내가 TabWidget

<TabWidget 
    android:id="@android:id/tabs" 
    android:layout_alignParentBottom="true" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/gray_light" /> 
에 배경 색상을 지정하여 그것을 해결