在应用栏中添加自定义布局

时间:2015-12-27 13:13:15

标签: android xml android-layout material-design android-appbarlayout

我在相当长的一段时间内一直在处理这个问题,但没有成功。所以任何兴奋,线索...任何想法如何解决这一点是值得赞赏的。

我的问题: 我的应用栏中有一个搜索框。我使用了Link

我希望我的搜索视图与Gmail中的视图类似: enter image description here

但是我看起来像这样:(搜索视图显示在底部,而不是在汉堡包图标和选项菜单之间)。 enter image description here

我在delay_auto_complete_text_view中检查根的任何类型的布局以及我设置的任何尺寸,搜索框都没有出现在顶部。我该如何解决这个问题?

我也尝试了appcompat搜索视图,但由于其他一些问题,我也无法使用它。 (比如旧版Android中的建议等)

这里是“app_bar.xml”:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
    xmlns:android = "http://schemas.android.com/apk/res/android"
    xmlns:app = "http://schemas.android.com/apk/res-auto"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    >

    <android.support.v7.widget.Toolbar
        android:layoutDirection = "rtl"
        android:id = "@+id/toolbar"
        android:layout_width = "match_parent"
        android:layout_height = "fill_parent"
        android:minHeight = "?attr/actionBarSize"
        android:background = "?attr/colorPrimary"
        app:contentInsetStart = "0dp"
        app:contentInsetEnd = "0dp"
        android:theme = "@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme = "@style/ThemeOverlay.AppCompat.Light"
        />

    <include
        android:id = "@+id/app_bar"
        layout = "@layout/delay_auto_complete_text_view"
        >
    </include>

</android.support.design.widget.AppBarLayout>

和我的delay_auto_complete_text_view.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
              style = "@style/StyleForHorizontalLinearLayout"
              android:id = "@+id/linear_layout_delay_auto_complete_text_view"
          android:layout_width = "match_parent"
          android:layout_height = "wrap_content"
    >

<LinearLayout
        android:layoutDirection = "rtl"
        android:orientation = "vertical"
        android:id = "@+id/container"
        android:layout_width = "match_parent"
        android:layout_height = "match_parent"
        >

    <com.jahanjooy.khoonat.View.DelayAutoCompleteTextView
            android:id = "@+id/et_book_title"
            android:textColor = "@android:color/white"
            android:inputType = "textCapSentences"
            android:layout_width = "match_parent"
            android:layout_height = "wrap_content"
            android:paddingRight = "20dp"
            android:imeOptions = "flagNoExtractUi|actionSearch"
            />
    <ProgressBar
            android:indeterminate = "true"
            android:indeterminateTintMode = "src_atop"
            android:indeterminateTint = "@android:color/white"

            android:id = "@+id/pb_loading_indicator"
            style = "?android:attr/progressBarStyleSmall"
            android:layout_width = "wrap_content"
            android:layout_height = "wrap_content"
            android:layout_gravity = "center_vertical|left"
            android:layout_marginRight = "30dp"
            android:visibility = "gone"
        />
    </LinearLayout>
</LinearLayout>

编辑: enter image description here

0 个答案:

没有答案