gpt4 book ai didi

android - 删除选择的 native ActionBar 突出显示

转载 作者:行者123 更新时间:2023-11-29 21:03:55 24 4
gpt4 key购买 nike

我想删除 Android ActionBar 中项目选择的默认突出显示,我正在使用 AppCompat

icon on right get select

我尝试通过设置颜色、透明形状或事件可绘制透明 png 将 android:selectableItemBackground 设置为透明,但没有成功

<style name="NActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">@android:color/transparent</item>
<item name="android:titleTextStyle">@android:color/white</item>
<item name="android:selectableItemBackground">@android:color/transparent</item>
<item name="android:background">@drawable/ab_transparent_example</item>
</style>

[编辑]

样式.xml

<?xml version="1.0" encoding="utf-8"?>
<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">
<!--
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="NTheme" parent="AppBaseTheme">
<item name="android:windowContentOverlay">@null</item>
<item name="android:buttonStyle">@style/NButton</item>
<item name="android:editTextStyle">@style/NEditText</item>
<item name="android:actionBarStyle">@style/NActionBar</item>
</style>

<style name="NThemeNoActionBar" parent="NTheme">
<item name="android:windowActionBar">false</item>
</style>

<style name="NButton" parent="android:style/Widget.Button">
<item name="android:background">@drawable/big_button</item>
<item name="android:textColor">@android:color/white</item>
</style>

<style name="NSmallButton" parent="android:style/Widget.Button">
<item name="android:background">@drawable/small_button</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">10sp</item>
</style>

<style name="NEditText" parent="android:style/Widget.EditText">
<item name="android:background">@android:color/transparent</item>
<item name="android:textColor">@color/blue</item>
<item name="android:textColorHint">@color/blue</item>
</style>

<!-- ActionBar styles -->
<style name="NActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">@android:color/transparent</item>
<item name="android:titleTextStyle">@android:color/white</item>
<item name="android:selectableItemBackground">@android:color/transparent</item>
<item name="android:background">@drawable/ab_transparent_example</item>
</style>

<style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@null</item>
<item name="metaButtonBarStyle">@style/ButtonBar</item>
<item name="metaButtonBarButtonStyle">@style/ButtonBarButton</item>
</style>

<style name="ButtonBar">
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingRight">2dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:background">@android:drawable/bottom_bar</item>
</style>

<style name="ButtonBarButton" />

<style name="FullHeightDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>

最佳答案

actionBarItemBackground 主题属性将允许您更改操作项选择器。

如果您将它与 ActionBarSherlock 或 ActionBarCompat 一起使用,请务必提供带有或不带 android: 前缀的条目。

在您的风格中,您可以使用以下几行:

<item name="android:actionBarItemBackground">@drawable/my_drawable</item>
<item name="actionBarItemBackground">@drawable/my_drawable</item>

希望对你有帮助

关于android - 删除选择的 native ActionBar 突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25114443/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com