简体   繁体   English

PhoneGap-Android应用程序中的样式和主题

[英]PhoneGap - Styles and themes in Android app

I'm building an Android app using PhoneGap, and would like to make the copy/share menu that shows up after a long click on text to overlay the app. 我正在使用PhoneGap构建一个Android应用程序,并希望制作一个复制/共享菜单,该菜单会在长时间单击文本以覆盖该应用程序后显示。 To do so, I have to set android:windowActionBar to true . 为此,我必须将android:windowActionBar设置为true This is what docs say: 这就是文档所说的:

Beware that hiding and removing the action bar causes your activity to re-layout in order to account for the space consumed by the action bar. 请注意,隐藏和删除操作栏会导致您的活动重新布局,以解决操作栏所消耗的空间。 If your activity regularly hides and shows the action bar (such as in the Android Gallery app), you might want to use overlay mode. 如果您的活动定期隐藏并显示操作栏(例如在Android Gallery应用程序中),则可能要使用覆盖模式。 Overlay mode draws the action bar on top of your activity layout rather than in its own area of the screen. 重叠模式会将操作栏绘制在活动布局的顶部,而不是在屏幕的自身区域。 This way, your layout remains fixed when the action bar hides and re-appears. 这样,当隐藏和重新显示操作栏时,布局将保持固定。 To enable overlay mode, create a theme for your activity and set android:windowActionBarOverlay to true. 要启用覆盖模式,请为您的活动创建一个主题,然后将android:windowActionBarOverlay设置为true。

So I tried to apply this theme: 所以我尝试应用这个主题:

<resources>
    <style name="AppTheme" parent="android:Theme.Holo.Light">
        <item name="android:windowActionBarOverlay">true</item>
    </style>
</resources>

to my application: 对我的应用程序:

<application
        android:icon="@drawable/icono_p"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

with no success. 没有成功。

Is there any way to set android:windowActionBar to true in a PhoneGap application? 有什么方法可以在PhoneGap应用程序中将android:windowActionBar设置为true

EDIT: 编辑:

The theme is actually being applied, but it just doesn't work as expected, the bar keeps resizing the app 该主题实际上已被应用,但是它不能按预期工作,该栏会不断调整应用的大小

I am pretty sure you would have to write a plugin for that for lower android versions. 我很确定您将为此较低的android版本编写一个插件。 I am not sure since when this function is available but on my ICS 4.0 i can just copy and share any text out of any phonegap app without declaring anything special. 我不确定该功能何时可用,但是在我的ICS 4.0上,我可以从任何phonegap应用程序中复制和共享任何文本,而无需声明任何特殊功能。 its a system function and it should just work the same way you would copy and share text out of a standard browser. 它是一项系统功能,它的工作方式应与从标准浏览器复制和共享文本的方式相同。 what are you testing it on and which version? 您在什么版本上测试它?

Solved it. 解决了。 The problem was that the copy/share menu is not an action bar, but a contextual action bar shown when the contextual action mode starts. 问题在于复制/共享菜单不是操作栏,而是上下文操作模式启动时显示的上下文操作栏。 So, instead of android:windowActionBar , the property to be set to true is android:windowActionModeOverlay 因此,要设置为true的属性不是android:windowActionBar ,而是android:windowActionModeOverlay

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM