如何删除文字和图案或使用AppCompat的API 8 Android上动作条增加溢出? [英] How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8?
问题描述
已经研究了这一死刑,只是无法找到答案。
我有利用AppCompat的动作条。我支持高达API V7(API V8会做)。动作条完美的作品,从API V11。 API< V11有没有提供一个溢出去除的动作条图标(因而功能)的问题。的大背景是,我有一个应用程序标志,一个App Title和3图标都squidging插入一个低端手机相同的动作条。试图让一些空间!
我会很乐意与1 2的解决方案。或者:
- 在收到一个溢出,这样的功能可以从下拉被检索的方法。
- (preferred)从动作条图标和文本的方法
下面是我当前的XML API为11 +:
<资源>
<! -
基本应用主题API 11+。这个主题完全取代
AppBaseTheme从API 11+设备RES /价值/ styles.xml。
- >
<样式名称=AppBaseTheme父=Theme.AppCompat.Light.DarkActionBar>
<项目名称=机器人:actionBarStyle> @风格/ LiteActionBarStyle< /项目>
<项目名称=actionBarStyle> @风格/ LiteActionBarStyle< /项目>
< /风格>
<样式名称=LiteActionBarStyle父=@风格/ Widget.AppCompat.Light.ActionBar.Solid.Inverse>
<项目名称=机器人:displayOptions>< /项目>
< /风格>
< /资源>
具体做法是:
<项目名称=机器人:displayOptions>< /项目>
这ISS即API V11之前不可用的属性。
这是我在哪里至今:
<资源的xmlns:机器人=http://schemas.android.com/apk/res/android>
<! -
基本应用的主题,依赖于API级别。这个主题被替换
通过AppBaseTheme从RES /值-VXX /上较新的设备styles.xml。
- >
<样式名称=AppBaseTheme父=Theme.AppCompat.Light.DarkActionBar>
<项目名称=actionBarStyle> @风格/ LiteActionBarStyle< /项目>
< /风格>
<样式名称=LiteActionBarStyle父=@风格/ Widget.AppCompat.Light.ActionBar.Solid.Inverse>< /风格>
< /资源>
什么是在V11之前的替代API的?
编辑:
与透明度的建议更新方式:
<资源的xmlns:机器人=http://schemas.android.com/apk/res/android>
<! -
基本应用的主题,依赖于API级别。这个主题被替换
通过AppBaseTheme从RES /值-VXX /上较新的设备styles.xml。
- >
<样式名称=AppBaseTheme父=Theme.AppCompat.Light.DarkActionBar>
<项目名称=actionBarStyle> @风格/ LiteActionBarStyle< /项目>
< /风格>
<样式名称=LiteActionBarStyle父=@风格/ Widget.AppCompat.Light.ActionBar.Solid.Inverse>
<项目名称=机器人:图标> @android:彩色/透明< /项目>
< /风格>
< /资源>
解决它!
在与API&LT工作; V11,你必须删除了机器人在样式属性的元素。例如:
<样式名称=LiteActionBarStyle父=@风格/ Widget.AppCompat.Light.ActionBar.Solid.Inverse>
<项目名称=displayOptions>< /项目>
< /风格>
这是怎样看的样式与API> = V11
<样式名称=AppBaseTheme父=Theme.AppCompat.Light.DarkActionBar>
<项目名称=机器人:actionBarStyle> @风格/ LiteActionBarStyle< /项目>
<项目名称=actionBarStyle> @风格/ LiteActionBarStyle< /项目>
< /风格>
<样式名称=LiteActionBarStyle父=@风格/ Widget.AppCompat.Light.ActionBar.Solid.Inverse>
<项目名称=机器人:displayOptions>< /项目>
< /风格>
另外,我错过了一些图标,当我应用这个设备上使用API< V11。我不得不改变图标总是显示:
<项目
机器人:ID =@ + ID / actionInvertShake
MyApp的:showAsAction =总是
机器人:contentDescription =@字符串/ shakeChangeContentDescription
机器人:图标=@可绘制/换血
机器人:标题=@字符串/ shakeOption/>
请注意,该命名空间是MyApp的,而不是机器人
这将删除应用程序从动作条的标题和图标显示从右所有图标到左。
Have researched this to death and just cannot find the answer.
I have an ActionBar using AppCompat. I am supporting up to API v7 (API v8 would do). ActionBar works perfectly from API v11. API < v11 has the problem of removing an icon (and thus a feature) from the ActionBar without supplying an Overflow. The big picture is that I have an App Logo, an App Title, and 3 Icons all squidging into the same ActionBar on a low end phone. Trying to make some room!
I would be happy with 1 of 2 solutions. Either:
- A method of getting an Overflow so that the functionality can be retrieved from a pull down.
- (Preferred) A method of removing the icon and text from ActionBar
Below is my current XML for API 11+:
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/LiteActionBarStyle</item>
<item name="actionBarStyle">@style/LiteActionBarStyle</item>
</style>
<style name="LiteActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:displayOptions"></item>
</style>
</resources>
Specifically:
<item name="android:displayOptions"></item>
This iss the attribute that is unavailable before API v11.
This is where I am so far:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
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="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/LiteActionBarStyle</item>
</style>
<style name="LiteActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"></style>
</resources>
What is the alternative for APIs prior to v11?
EDIT:
Updated Style with transparency suggestion:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
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="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/LiteActionBarStyle</item>
</style>
<style name="LiteActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">@android:color/transparent</item>
</style>
</resources>
Solved it!
When working with API < v11, you have to remove the "android:" element of the attribute in Style. For example:
<style name="LiteActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="displayOptions"></item>
</style>
This is how it should look in Styles with API >= v11
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/LiteActionBarStyle</item>
<item name="actionBarStyle">@style/LiteActionBarStyle</item>
</style>
<style name="LiteActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:displayOptions"></item>
</style>
Also, I was missing some Icons when I applied this on device with API < v11. I had to change the Icons to Always display:
<item
android:id="@+id/actionInvertShake"
MyApp:showAsAction="always"
android:contentDescription="@string/shakeChangeContentDescription"
android:icon="@drawable/shake"
android:title="@string/shakeOption"/>
Note that the Namespace is "MyApp" rather than "android"
This removes the Title and Icon of App from ActionBar and displays all icons from Right to Left.
这篇关于如何删除文字和图案或使用AppCompat的API 8 Android上动作条增加溢出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!