Searchview与自定义操作栏的其他视图重叠

时间:2015-06-03 06:57:09

标签: android android-actionbar searchview appcompat-v7-r22.1

我使用appcompat v7支持库实现了自定义操作栏。 为此我创建了具有所需视图的自定义布局。 我也将SearchView放在自定义布局中。

最后我得到了所需的输出,如下所示。enter image description here

问题::

当我点击搜索视图时,视图重叠在布局的另一个看起来非常难看的视图上。

enter image description here

我希望通常像吹屏一样表现出searhview ..

请让我知道我哪里错了..

任何建议/摘要都会有所帮助。

CustomActionBar Layout ::

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:yourapp="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp" >

    <ImageView
        android:id="@+id/imgAppIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/txtAppName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@+id/imgAppIcon"
        android:text="Test App"
        android:textSize="16sp"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/imgOVerflow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/icon_overflow" />

    <android.support.v7.widget.SearchView
        android:id="@+id/imgsearchView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/imgOVerflow"
        yourapp:actionViewClass="android.support.v7.widget.SearchView"
        yourapp:iconifiedByDefault="true"
        yourapp:showAsAction="ifRoom|collapseActionView" />

</RelativeLayout>

HomeActivity.java

    actionBar = getSupportActionBar();
 actionBar.removeAllTabs();
 getSupportActionBar().setHomeButtonEnabled(true);
 getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
 getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
 getSupportActionBar().setCustomView(R.layout.custom_actionbar_home);getSupportActionBar().setDisplayShowCustomEnabled(true);

 ImageView imgOverFlowMenu = (ImageView) getSupportActionBar().getCustomView().findViewById(R.id.imgOVerflow);

0 个答案:

没有答案