我创建的应用程序具有与浏览器类似的功能。这就是我现在所拥有的:
每当用户点击edittext(其中包含google.com的那个)时,我想在操作栏中占用所有空间,包括溢出按钮和其他图标(这些也是菜单项)。
有什么方法可以做到吗?到目前为止,我已经尝试将edittext的layout-weight设置为1,但它不起作用。操作栏内的自定义视图是这样的线性布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/searchfield"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:imeOptions="actionGo"
android:inputType="textWebEmailAddress"
android:text="www.google.com" />
</LinearLayout>
我还应该提一下,我想以编程方式进行。
谢谢你们
答案 0 :(得分:0)
您可以通过以下主题隐藏这些图标:How do I hide a menu item in the actionbar?
我认为您可以在点击时轻松隐藏操作栏 类似的东西:
ActionBar actionBar = getActionBar(); //OR getSupportActionBar();
actionBar.hide();
然后在需要时使用以下内容将其恢复:
actionBar.show();