转自:http://blog.csdn.net/hnxxwyq/article/details/8632769

在android中2.3.x使用ActionBar,需要有actionbarshelock的支持,至于这么加入actionbarshelock的支持,可以移步这里-开源组件actionbarsherlock的使用

建立样式文件values/themes.xml,内容如下

[html] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <resourcesxmlns:android="http://schemas.android.com/apk/res/android">
  3. <!--父类为Theme.Sherlock.Light,即白底黑字(如果是Theme.Sherlock,则为黑底白字),为了兼容考虑,所有样式的相关item需要写2遍-->
  4. <stylename="Theme.DEMO"parent="Theme.Sherlock.Light">
  5. <itemname="actionBarStyle">@style/Widget.DEMO.ActionBar</item>
  6. <itemname="android:actionBarStyle">@style/Widget.DEMO.ActionBar</item>
  7. </style>
  8. <!--标题栏的样式-->
  9. <stylename="Widget.DEMO.ActionBar"parent="Widget.Sherlock.ActionBar.Solid">
  10. <itemname="background">#1791d2</item>
  11. <itemname="backgroundStacked">#1791d2</item>
  12. <itemname="backgroundSplit">#1791d2</item>
  13. <itemname="titleTextStyle">@style/Widget.DEMO.ActionBar.Title</item>
  14. <itemname="android:background">#1791d2</item>
  15. <itemname="android:backgroundStacked">#1791d2</item>
  16. <itemname="android:backgroundSplit">#1791d2</item>
  17. <itemname="android:titleTextStyle">@style/Widget.DEMO.ActionBar.Title</item>
  18. </style>
  19. <!--标题栏的标题样式-->
  20. <stylename="Widget.DEMO.ActionBar.Title"parent="@android:TextAppearance.Holo.Widget.ActionBar.Title">
  21. <itemname="android:textColor">#fff</item>
  22. </style>
  23. </resources>



而activity类则需要继承自SherlockActivity或者 SherlockFragmentActivity

[java] view plain copy
  1. packagecom.game178.lolmobiledhelper;
  2. importandroid.os.Bundle;
  3. importcom.actionbarsherlock.app.SherlockFragmentActivity;
  4. publicclassItemInfoextendsSherlockFragmentActivity{
  5. @Override
  6. protectedvoidonCreate(BundlesavedInstanceState){
  7. super.onCreate(savedInstanceState);
  8. setContentView(R.layout.item_info);
  9. }
  10. }



效果如下



参考自:https://groups.google.com/forum/?fromgroups=#!topic/actionbarsherlock/TiJYM_TKhb8

更多相关文章

  1. 【React Native开发】 - react-native-swiper的使用
  2. android开发之修改ListView默认滑动条样式
  3. 自定义RatingBar/SeekBar,重载样式
  4. Android(安卓)常用控件自定义样式RadioButton、CheckBox、Progre
  5. android自定义Spinner的下拉样式(setDropDownViewResource)
  6. IIS 添加mime 支持 apk,exe,.woff,IIS MIME设置 ,Android(安卓)apk
  7. Android(安卓)DigitalClock
  8. android中listview中设计左图标
  9. 2019最新Android常用开源库总结(From:知乎)

随机推荐

  1. list滑动删除item
  2. Android腾讯微博客户端开发三:多账号管理
  3. http通信,Android(安卓)Gzip压缩解压
  4. Android(安卓)连接.net WebService 工具
  5. java.lang.RuntimeException: Unable to
  6. 日志工具类
  7. Android组件 文字标签(TextView)
  8. Android(安卓)调用H5界面(交互)
  9. java.lang.NullPointerException: Attemp
  10. linux下编译MTK android的环境搭建