在Android中,如何在使用主题时覆盖EditText longpress弹出窗口以包含“剪贴板”选项?

时间:2015-05-15 17:04:28

标签: android android-theme

我使用Android资源工作室创建了一个主题,我已经应用了它 - 看起来很棒。

但是,现在当我长按EditText时,我只会将“粘贴”选项显示为文本。如果没有应用主题,长按EditText会弹出更强大的UI,显示粘贴和剪贴板。我必须拥有剪贴板选项。

我知道我可以创建一个自定义的长按视图。但我希望能够简单地覆盖主题覆盖原始长按行为。

以下是一些截图...

主题(不够好):
enter image description here

没有主题(我想要的):
enter image description here

以下是主题样式文件中的代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator

     Copyright (C) 2011 The Android Open Source Project
     Copyright (C) 2012 readyState Software Ltd

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<resources>

    <style name="Theme.Ibgib_green" parent="@android:style/Theme.Holo">
        <item name="android:actionBarItemBackground">@drawable/selectable_background_ibgib_green</item>
        <item name="android:popupMenuStyle">@style/PopupMenu.Ibgib_green</item>
        <item name="android:dropDownListViewStyle">@style/DropDownListView.Ibgib_green</item>
        <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Ibgib_green</item>
        <item name="android:actionDropDownStyle">@style/DropDownNav.Ibgib_green</item>
        <item name="android:actionBarStyle">@style/ActionBar.Solid.Ibgib_green</item>
        <item name="android:actionModeBackground">@drawable/cab_background_top_ibgib_green</item>
        <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_ibgib_green</item>
        <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Ibgib_green</item>


    </style>

    <style name="ActionBar.Solid.Ibgib_green" parent="@android:style/Widget.Holo.ActionBar.Solid">
        <item name="android:background">@drawable/ab_solid_ibgib_green</item>
        <item name="android:backgroundStacked">@drawable/ab_stacked_solid_ibgib_green</item>
        <item name="android:backgroundSplit">@drawable/ab_bottom_solid_ibgib_green</item>
        <item name="android:progressBarStyle">@style/ProgressBar.Ibgib_green</item>
    </style>

    <style name="ActionBar.Transparent.Ibgib_green" parent="@android:style/Widget.Holo.ActionBar">
        <item name="android:background">@drawable/ab_transparent_ibgib_green</item>
        <item name="android:progressBarStyle">@style/ProgressBar.Ibgib_green</item>
    </style>

    <style name="PopupMenu.Ibgib_green" parent="@android:style/Widget.Holo.ListPopupWindow">
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_ibgib_green</item>   
    </style>

    <style name="DropDownListView.Ibgib_green" parent="@android:style/Widget.Holo.ListView.DropDown">
        <item name="android:listSelector">@drawable/selectable_background_ibgib_green</item>
    </style>

    <style name="ActionBarTabStyle.Ibgib_green" parent="@android:style/Widget.Holo.ActionBar.TabView">
        <item name="android:background">@drawable/tab_indicator_ab_ibgib_green</item>
    </style>

    <style name="DropDownNav.Ibgib_green" parent="@android:style/Widget.Holo.Spinner">
        <item name="android:background">@drawable/spinner_background_ab_ibgib_green</item>
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_ibgib_green</item>
        <item name="android:dropDownSelector">@drawable/selectable_background_ibgib_green</item>
    </style>

    <style name="ProgressBar.Ibgib_green" parent="@android:style/Widget.Holo.ProgressBar.Horizontal">
        <item name="android:progressDrawable">@drawable/progress_horizontal_ibgib_green</item>
    </style>

    <style name="ActionButton.CloseMode.Ibgib_green" parent="@android:style/Widget.Holo.ActionButton.CloseMode">
        <item name="android:background">@drawable/btn_cab_done_ibgib_green</item>
    </style>

    <!-- this style is only referenced in a Light.DarkActionBar based theme -->
    <style name="Theme.Ibgib_green.Widget" parent="@android:style/Theme.Holo">
        <item name="android:popupMenuStyle">@style/PopupMenu.Ibgib_green</item>
        <item name="android:dropDownListViewStyle">@style/DropDownListView.Ibgib_green</item>
    </style>

1 个答案:

答案 0 :(得分:0)

好吧,我不知道如何让弹出窗口正常工作。但我确实(可能)学习了为什么弹出窗口简化为&#34;粘贴&#34;没有经理选项。

在我的标准键盘(Samsung S3 / 4/6)上,有一个剪贴板按钮,可通过长按空格键左侧的其中一个按钮进行访问。这样就不需要弹出窗口中的剪贴板管理器。