Android 如何禁用S3上的硬件菜单按钮弹出操作项?
我只是在Galaxy S3上测试我的应用程序。它在手机上有一个硬件菜单按钮 我使用一个活动来保存一些片段,每个片段都有自己的要显示的操作栏项。它在其他手机上运行良好,而且就动作栏部分而言,它在S3上运行良好 我的问题是在S3上,当我单击硬件菜单按钮时,它会弹出一个列表,其中包含片段上定义的所有当前操作项名称。弹出列表位于屏幕底部。请看下面的截图 我想知道是否有一种方法可以禁用这种行为?我希望该应用程序将忽略硬件菜单按钮的点击,只允许用户使用操作栏上的按钮。我尝试过使用dispatchKeyEvent和CheckKeycod_菜单,但似乎不起作用 谢谢大家! 更新: 主题: 在“值”文件夹中的styles.xml:Android 如何禁用S3上的硬件菜单按钮弹出操作项?,android,android-layout,android-actionbar,android-menu,android-optionsmenu,Android,Android Layout,Android Actionbar,Android Menu,Android Optionsmenu,我只是在Galaxy S3上测试我的应用程序。它在手机上有一个硬件菜单按钮 我使用一个活动来保存一些片段,每个片段都有自己的要显示的操作栏项。它在其他手机上运行良好,而且就动作栏部分而言,它在S3上运行良好 我的问题是在S3上,当我单击硬件菜单按钮时,它会弹出一个列表,其中包含片段上定义的所有当前操作项名称。弹出列表位于屏幕底部。请看下面的截图 我想知道是否有一种方法可以禁用这种行为?我希望该应用程序将忽略硬件菜单按钮的点击,只允许用户使用操作栏上的按钮。我尝试过使用dispatchKeyEve
<?xml version="1.0" encoding="utf-8"?> <resources>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="contentInsetStart">0dp</item>
</style>
<style name="Widget.Toolbar" parent="@style/Widget.AppCompat.Toolbar">
<item name="contentInsetStart">0dp</item>
</style>
<!-- Style user drawer -->
<style name="textView_title_list" parent="android:Widget.TextView">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@drawable/bg_black_transparent</item>
<item name="android:ellipsize">end</item>
<item name="android:padding">4dp</item>
<item name="android:layout_gravity">bottom</item>
</style>
<!-- ToolBar -->
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="SmallTitleText" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">10sp</item>
<item name="android:textColor">@color/white</item>
<item name="android:textStyle">bold</item>
<item name="android:typeface">sans</item>
</style>
<style name="TextAppearance.Widget.ActionBar.Title"
parent="@android:style/TextAppearance.Small">
</style>
</resources>
真的
假的
@样式/抽屉箭头样式
真的
0dp
0dp
匹配父项
包装内容
@可拉伸/背景为黑色或透明
结束
4dp
底部
@android:彩色/白色
@android:彩色/白色
@样式/抽屉箭头样式
10便士
@颜色/白色
大胆的
桑
在v21中:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>
真的
真的
真的
@android:过渡/移动
@android:过渡/移动
您正在使用支持库吗?如果是,哪个版本?对于最新版本,S2上我的应用程序中的硬件菜单按钮被忽略。也许你可以尝试使用最新版本。我正在使用com.android。支持:appcompat-v7:22.1.0和com.android。支持:support-v4:22.0.0你在使用哪个主题?我已将主题文件更新到帖子中。非常感谢。我也面临同样的问题。你有什么解决办法吗?