【问题标题】:Android: full-width SearchView in ActionBarAndroid:ActionBar 中的全角 SearchView
【发布时间】:2014-07-21 09:57:17
【问题描述】:

我希望 SearchView 完全占据 ActionBar 的整个宽度(支持 v7),但即使在调用之后...

actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);

...我在左边得到一个空格:

【问题讨论】:

标签: android android-actionbar


【解决方案1】:

我通过使用工具栏并设置以下参数解决了这个问题:

    <android.support.v7.widget.Toolbar
        android:id="@+id/tbToolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:paddingLeft="0dp"
        android:background="?attr/colorPrimary"
        android:contentInsetLeft="0dp"
        android:contentInsetStart="0dp"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp"
        app:contentInsetStartWithNavigation="0dp">

您可以在其中放置一个 SearchView 或将您的工具栏项与具有工具栏视图的 menu.xml 一起使用。请参阅 android 开发者文档。

【讨论】:

    猜你喜欢
    • 2012-04-11
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多