我的工具栏和EditText如下所示:
我尝试将其添加为ActionView,但我得到这个结果:
它基本上只是添加了我的单词“点击下面”作为标题没有TextView
这是我做的:
menu.xml文件
<menu> ... ... <item android:id="@+id/edit_text_menu" android:orderInCategory="300" android:title="Tap Below" android:actionLayout="@layout/edit_text_layout" app:showAsAction="ifRoom|collapseActionView" /> </menu>
edit_text_layout.xml
<?xml version="1.0" encoding="utf-8"?> <EditText xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/myEditText" android:background="#000000"> </EditText>
我想通过这样做,我将EditText布局添加到工具栏…
有人可以帮忙吗?
或者,是否有一个技巧可以在工具栏上覆盖EditText?
我尝试添加< item name =“windowActionModeOverlay”> true< / item>但它没有做任何事情.
解决方法
只需将EditText添加到您的ToolBar的XML.这可能是最简单的方法.
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> <EditText android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/myEditText" android:background="#000000" /> </android.support.v7.widget.Toolbar>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。