0
我正在開發,需要用行動欄和標籤欄工作的一個應用程序,我的第一個問題是建立一個自定義文本樣式標籤欄上的標籤,現在我想用操作欄,但我遇到了自定義樣式和操作欄的麻煩。我做了一個自定義的樣式,以便:設置自定義風格和操作欄
styles.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="CustomTheme" parent="@android:style/Theme">
<item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
現在我讀here,我可以添加一個動作欄自定義樣式,所以我嘗試這樣做:
styles.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="CustomTheme" parent="@android:style/Theme">
<item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="Widget.ActionBar" parent="android:Widget.Holo.Light.ActionBar">
<item name="android:displayOptions">showHome|useLogo|showCustom</item>
<item name="android:customNavigationLayout">@layout/custom</item>
</style>
</resources>
如果你看一下我的XML代碼,你可以看到,我想補充Widget.ActionBar樣式在我的活動上顯示一個操作欄。當我嘗試運行我的應用程序時,我可以看到選項卡主機的自定義樣式,但我看不到操作欄。 我需要操作欄來放置分享按鈕。 你能幫我嗎?
我插你的解決方案,但它提供了12個錯誤...我張貼[這裏](http://postimg.org/image/4n67cramf/)我styles.xml的截圖,我希望你能幫助我修復這個問題,謝謝 – lucgian84
@ lucgian84哦對不起。我在我的項目中添加了ActionbarSerlock庫,這就是爲什麼你有錯誤。等等,讓我更新答案。 –
我會看看你的建議。現在感謝您 – lucgian84