android-将开关按钮设置为带有showAsAction ="never"的操作栏. [英] android - Set switch button into action bar with showAsAction="never"
问题描述
我想使用showAsAction ="never"将一个切换按钮放入MenuItem中,但是它不起作用.这是我的布局
I want to put a switch button into MenuItem with showAsAction="never" but it's not working. Here is my layout
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.trietnhm.multipleactivities.MainActivity"
>
<item
android:id="@+id/action_about"
android:orderInCategory="0"
app:showAsAction="never"
android:title="About"/>
<item
android:id="@+id/action_change_theme"
android:orderInCategory="3"
app:actionLayout="@layout/switcher"
app:showAsAction="never"
android:title="" />
<item
android:id="@+id/action_change_delimeter"
android:orderInCategory="2"
app:showAsAction="never"
android:title="Change Delimeter"/>
</menu>
这是我的切换按钮
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v7.widget.SwitchCompat
android:id="@+id/switchForActionBar"
android:layout_width="70dp"
android:layout_height="50dp"
android:scaleX="1.3"
android:scaleY="1.3"
android:switchMinWidth="45dp"
android:paddingTop="6dp" />
</RelativeLayout>
当我运行该应用程序时,它什么也没有显示.此处的图像 https://drive.google.com/file/d/0B5zsq6J-qyY5bF8tYnBKVy11OHM/view?usp = sharing
When I run the app and it's not show anything. Here the image https://drive.google.com/file/d/0B5zsq6J-qyY5bF8tYnBKVy11OHM/view?usp=sharing
任何帮助,我将不胜感激.谢谢大家.
Any help I would be appreciated. Thanks all.
推荐答案
never
:
切勿将此项放置在应用栏中.相反,请在 应用栏的溢出菜单.
Never place this item in the app bar. Instead, list the item in the app bar's overflow menu.
当然,它不会显示.也许您应该使用其他选项来显示always
或ifRoom
.
Of course, It won't show up. Perhaps you should use other options to show, always
or ifRoom
.
这篇关于android-将开关按钮设置为带有showAsAction ="never"的操作栏.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!