Step1 : create three background image (a)when tab is selected(b)when tab is in default state(c)when tab is focused.
Step2 : create selector xml under drawable folder.
e.g: actionbar_tabs_state_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_default"/>
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected"/>
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focused"/>
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focused"/>
<!-- Pressed -->
<item android:state_pressed="true" android:drawable="@drawable/tab_focused"/>
</selector>
Step3: create new style element in style.xml
<style name="customActionBarTabStyle">
<item name="android:background">@drawable/actionbar_tabs_state_color</item>
<item name="android:paddingLeft">14dp</item>
<item name="android:paddingRight">14dp</item>
</style>
Step4 : create new style element in style.xml to set “customActionBarTabStyle” style.
<style name="CustomActionBar" parent="android:style/Theme.Holo">
<item name="android:actionBarTabStyle">@style/customActionBarTabStyle</item>
</style>
Step5: Use style element created in step4 in your activity attribute in AndroidManifest.xml
case 1: just for one activity
<activity android:name=".base.activity.MyActivity"
android:screenOrientation="sensorLandscape" android:theme="@style/CustomActionBar">
</activity>
case 2: all the activity
<application android:theme="@style/AppTheme"> </application>
分享到:
相关推荐
Fragment ViewPager actionBar FragmentPagerAdapter ActionBar.Tab
这是我查看官方帮助文档完成的一个关于actionBar的例子,包括自定义菜单,和用actionBar实现菜单导航功能。
低版本兼容ActionBar和Tab的样式修改,
低版本兼容的ActionBar中添加Tab+Fragment,
ActionBar用Tab+ViewPager+Fragment实现快速导航,
EffectiveNavigation:ActionBar.Tab导航和PagerTitleStrip导航,源码来自Android开发者官网,加了一点个人的学习笔记
ActionBar.Tab 与 ViewPager关联使用,支持点击tab切换页面和滑动切换页面。
Template.Tab-based-ActionBar-Style.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
Cangol-ActionBar 是一款Android自定义ActionBar组件。 截图: 使用: Maven <groupId>mobi.cangol.mobile <artifactId>actionbar <version>1.0.1 <type>aar Gradle compile 'mobi...
Custom ActionBar介绍: 自定义Action Bar。 测试环境: Eclipse 4.2, Android 3.0 以上。 注意:测试环境并不代表适用环境。
android-actionbar 是一个标识应用程序和用户位置的窗口功能,并且给用户提供操作和导航模式。 标签:android
ActionBar实现Tab选项标签效果,项目包含:源码+效果图+项目结构图 教程地址:http://blog.csdn.net/yangyu20121224/article/details/9050573
使用ActionBar的Tab实现Tabhost的效果,同时,可对Tab的样式进行定制
ActionBarDemo actionBar的教程 1.获得ActionBar | // 获得ActionBar ActionBar actionBar = getSupportActionBar(); 2.显示/隐藏ActionBar | //显示ActionBar ...actionBar.setDisplayHomeAsUpEn
NULL 博文链接:https://18767136122.iteye.com/blog/2098563
本文实例讲述了Android...ActionBar Tab主要用于Fragment之间的切换,其必须要设置ActionBar.TabListener,详细代码如下 ActionBarActivity.Java: import android.app.ActionBar; import android.app.Activity; impor
Android 使用Fragment,ActionBar 实现tab标签切换页面的一个简单样例
该代码介绍了ActionBar中的Tab如何使用。
This is a simple implementation of ui gradients on android Actionbar. You liked it ? :smile: can you star :star: it ? Usage Usage is simple look at the source , still any trouble ? create an issue ...
ActionBar.