核心: 自定义的View
Android 开发------------------ 修改 Actionbar 的样式
Java代码:
actionBar = getSupportActionBar();
ActionBar.Tab t = actionBar.getTabAt(i);
t.setCustomView(R.layout.tab_layout_1);
TextView title = (TextView)t.getCustomView().findViewById(R.id.tab_title);
title.setBackgroundResource(R.drawable.detail);
title.setText(sectionID);
布局文件
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_gravity="center_vertical|center"
android:textColor="@android:color/holo_blue_dark"
android:textSize="14sp" />
</FrameLayout>