how to change the background of actionbar.tab
来源:互联网 发布:linux 修改北京时间 编辑:程序博客网 时间:2024/05/30 04:42
how to change the background of actionbar.tab
- 博客分类:
- Android App
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>
- how to change the background of actionbar.tab
- how to change the background color of actionbar
- How To Change the Background Color of a Tab Control
- qt 之 How to Change the Background Color of QWidget
- 如何修改Screen背景?How to - Change the background color of a screen
- How to change the text color of the selected property sheet tab in Visual C++
- how to change the port of tomcat
- How to change the background color of form using C++ - 如何用C++改变窗体的颜色
- A script to change the background of pdf file!
- How to customize the background color of a UITableViewCell?
- how to change root window background
- How to change the name of logfile dynamically using log4j
- How to change the color of a CEikLabel
- How to change the font size in legend of matlab
- How to Change the Hostname of a Linux System
- how to change the default mode of a linux device
- How to Change the Hostname of a Linux System
- How to change the dbo
- ListView美化:黑线问题
- zoj1092
- c++求两条直线的交点
- 常用Linux命令--文件管理
- 站点日志处理方法
- how to change the background of actionbar.tab
- IP数据报传输与处理过程
- PLY文件
- Android传感器 之 简介
- 鉴客 InputStream与String,Byte之间互转
- poj1679
- 假设有n个布尔变量x1, ..., xn,输出其所有可能的真值集合
- 小笨孩工作记
- 关于phpMyAdmin出现"#2000 无法登录 MySQL 服务器"的问题