简体   繁体   English

透明的Android上下文操作栏

[英]Transparent of Android Contextual Action Bar

A contexual action bar(CAB) will be shown when long tapping at TextEdit on Andriod WebView. 在Andriod WebView上的TextEdit上长按时,将显示一个contextic动作栏(CAB)。

I specified the following styles, in order to avoid that a layout breaks, but menu doesn't became transparent and hide TextEdit. 我指定了以下样式,以避免布局中断,但菜单没有变得透明并隐藏TextEdit。 What should I write with this menu for making it transparent? 为了使该菜单透明,我应该写些什么?

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="android:Theme.Holo">
        <item name="android:actionBarStyle">@style/AppStyle</item>
        <item name="android:windowActionModeOverlay">true</item>
    </style>
    <style name="AppStyle" parent="android:Widget.Holo.ActionBar">
        <item name="android:colorBackground">#00000000</item>
    </style>
</resources>

隐藏文字

Create a resource for your colors and reference them from there: 为您的颜色创建资源并从那里引用它们:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <color name="transparentBlack">#00000000</color>

</resources>

Change the AppStyle to this: 将AppStyle更改为此:

<style name="AppStyle" parent="android:Widget.Holo.ActionBar">

    <item name="android:background">@color/transparentBlack</item>

</style>

The main difference is background vs colorBackground, I'm not really sure if there is a functioning difference, but I know that when I compare my working transparent action bar style and your action bar style that is pretty much the only difference. 主要区别是背景与colorBackground,我不确定是否有功能上的区别,但是我知道,当我比较工作透明的操作栏样式和您的操作栏样式时,这几乎是唯一的区别。

You could try to change only the android:colorBackground to android:background and see if that alone works, but I've found it best to use references instead of hard coding colors directly. 您可以尝试仅将android:colorBackground更改为android:background,看看是否能单独使用,但我发现最好使用引用而不是直接对颜色进行硬编码。 If you are curious to change only one, try them separately to see if they solve your problem. 如果您只想更改一个,请单独尝试看它们是否可以解决您的问题。

NEW SUGGESTION AS OF 12.22.2014- 截至2014年22月22日的新建议

Why don't you just hide the action bar (mSpecialActionBar.hide();) and then implement a View.OnLongClickListener for your Activity. 为什么不隐藏操作栏(mSpecialActionBar.hide();),然后为Activity实现View.OnLongClickListener。 You can then show the action bar again (mSpecialActionBar.show();) on a long click. 然后,您可以长按一次再次显示操作栏(mSpecialActionBar.show();)。 Or something similar. 或类似的东西。

@Override
public void onLongClick(View v) {

    if (v.getClass() == TextEdit) {

       mSpecialActionBar.show();

    }
} // end-of-method onLongClick  

Here is a resource I found useful: http://java.dzone.com/articles/contextual-action-bar-cab 这是我发现有用的资源: http : //java.dzone.com/articles/contextual-action-bar-cab

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

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