2014-09-16 3 views
0

ViewPagerActionBar을 사용하여 Android에서 탭을 구현했습니다. 탭은 문제없이 작동하며 다음 이미지와 같이 기본 ActionBar 탭 헤더가 있습니다. Default tab headersAndroid 액션 바의 기본 스타일 변경하기 탭 헤더

하지만 아래 그림과 같이 헤더를 변경하고 싶습니다. 누군가가 나를 도울 수 있다면 정말 좋을 것입니다.

답변

0

이 액션 바 발생기 Generator

을 시도하거나 사용자 지정 스타일 작성하여 액션 바의 색상을 정의 할 수 있습니다

이동을하고

고해상도 편집 /values/styles.xml

Android 프로젝트의 파일입니다.

<resources> 
    <style name="MyCustomTheme" parent="@android:style/Theme.Holo.Light"> 
     <item name="android:actionBarStyle">@style/MyActionBarTheme</item> 
    </style> 

    <style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar"> 
     <item name="android:background">ANY_HEX_COLOR_CODE</item> 
    </style> 
</resources> 

는 그 다음 액션 바가 포함 된 활동의 테마로 "MyCustomTheme"로 설정 : 여기

은 예입니다.

또한이 같은 액션 바의 색상을 설정할 수 있습니다 : 당신이 포토샵이나 김프로 그것을 확인하고 9patch로 만들 필요가 자신의 표시를 만들기 위해

ActionBar actionBar = getActionBar(); 
actionBar.setBackgroundDrawable(new ColorDrawable(Color.RED)); // set your desired color 

편집

을 당김 다음 tab_unselected_holo이

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
     <!-- Non focused states --> 
     <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_holo" /> 
     <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_holo" /> 

     <!-- Focused states --> 
     <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_holo" /> 
     <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_holo" /> 

     <!-- Pressed --> 
     <!-- Non focused states --> 
     <item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_holo" /> 
     <item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_holo" /> 

     <!-- Focused states --> 
     <item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_focused_holo" /> 
     <item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_focused_holo" /> 
    </selector> 

다음이

같은 스타일의 XML 파일을 추가 PNG로 자신의 표시입니다 다음과 같이 선언
<style name="Widget.Holo.TabWidget" parent="Widget.TabWidget"> 
     <item name="android:tabStripLeft">@null</item> 
     <item name="android:tabStripRight">@null</item> 
     <item name="android:tabStripEnabled">false</item> 
     <item name="android:divider">?android:attr/dividerVertical</item> 
     <item name="android:showDividers">middle</item> 
     <item name="android:dividerPadding">8dip</item> 
     <item name="android:measureWithLargestChild">true</item> 
     <item name="android:tabLayout">@android:layout/tab_indicator_holo</item> 
    </style> 
+0

답장을 보내 주셔서 감사합니다. 표시된 두 번째 이미지에 표시기 화살표를 넣으 려합니다. 색깔은 문제가되지 않습니다. – PIKP

+0

환영합니다, 편집 됨 답변 –

관련 문제