在android 2.3.x中修改actionbarsherlock的样式
16lz
2021-01-26
转自:http://blog.csdn.net/hnxxwyq/article/details/8632769
在android中2.3.x使用ActionBar,需要有actionbarshelock的支持,至于这么加入actionbarshelock的支持,可以移步这里-开源组件actionbarsherlock的使用
建立样式文件values/themes.xml,内容如下
[html] view plain copy- <?xmlversion="1.0"encoding="utf-8"?>
- <resourcesxmlns:android="http://schemas.android.com/apk/res/android">
- <!--父类为Theme.Sherlock.Light,即白底黑字(如果是Theme.Sherlock,则为黑底白字),为了兼容考虑,所有样式的相关item需要写2遍-->
- <stylename="Theme.DEMO"parent="Theme.Sherlock.Light">
- <itemname="actionBarStyle">@style/Widget.DEMO.ActionBar</item>
- <itemname="android:actionBarStyle">@style/Widget.DEMO.ActionBar</item>
- </style>
- <!--标题栏的样式-->
- <stylename="Widget.DEMO.ActionBar"parent="Widget.Sherlock.ActionBar.Solid">
- <itemname="background">#1791d2</item>
- <itemname="backgroundStacked">#1791d2</item>
- <itemname="backgroundSplit">#1791d2</item>
- <itemname="titleTextStyle">@style/Widget.DEMO.ActionBar.Title</item>
- <itemname="android:background">#1791d2</item>
- <itemname="android:backgroundStacked">#1791d2</item>
- <itemname="android:backgroundSplit">#1791d2</item>
- <itemname="android:titleTextStyle">@style/Widget.DEMO.ActionBar.Title</item>
- </style>
- <!--标题栏的标题样式-->
- <stylename="Widget.DEMO.ActionBar.Title"parent="@android:TextAppearance.Holo.Widget.ActionBar.Title">
- <itemname="android:textColor">#fff</item>
- </style>
- </resources>
而activity类则需要继承自SherlockActivity或者 SherlockFragmentActivity
[java] view plain copy- packagecom.game178.lolmobiledhelper;
- importandroid.os.Bundle;
- importcom.actionbarsherlock.app.SherlockFragmentActivity;
- publicclassItemInfoextendsSherlockFragmentActivity{
- @Override
- protectedvoidonCreate(BundlesavedInstanceState){
- super.onCreate(savedInstanceState);
- setContentView(R.layout.item_info);
- }
- }
效果如下
参考自:https://groups.google.com/forum/?fromgroups=#!topic/actionbarsherlock/TiJYM_TKhb8
更多相关文章
- 【React Native开发】 - react-native-swiper的使用
- android开发之修改ListView默认滑动条样式
- 自定义RatingBar/SeekBar,重载样式
- Android(安卓)常用控件自定义样式RadioButton、CheckBox、Progre
- android自定义Spinner的下拉样式(setDropDownViewResource)
- IIS 添加mime 支持 apk,exe,.woff,IIS MIME设置 ,Android(安卓)apk
- Android(安卓)DigitalClock
- android中listview中设计左图标
- 2019最新Android常用开源库总结(From:知乎)