【问题标题】:remove blank space in toolbar layout删除工具栏布局中的空白
【发布时间】:2018-09-13 04:11:25
【问题描述】:
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/toolbarheight"
        android:background="@drawable/navigation_bar_top"
        app:popupTheme="@style/AppTheme.PopupOverlay">
        <LinearLayout
            android:layout_width="260dp"
            android:layout_height="match_parent"
            android:orientation="horizontal">
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/background_toolbar_main" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

所以我遇到了问题,我在工具栏部分有两个选项卡,但我不知道为什么我不能从左侧开始我的选项卡,我有一些间距,不知道如何删除它。

我尝试将所有填充设置为“0”或“false”,但找不到任何东西

【问题讨论】:

  • TabsToolbar 旁边?那是怎样的设计..?你不是在找NavigationDrawer 什么的吗?无论如何,您可能想考虑在LinearLayout 中添加Toolbar 以实现您想要的。

标签: android android-toolbar android-tablayout


【解决方案1】:

我不建议这样做,但是,您的问题的答案是将 ToolbarTabLayout 都放在 LinearLayout 中,如下所示:

<android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@color/red" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@color/orange" />
        </LinearLayout>

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

输出:

【讨论】:

  • 很高兴帮助朋友 ;] 但是考虑不要使用这些布局。
猜你喜欢
  • 2017-09-04
  • 1970-01-01
  • 2018-06-02
  • 2018-05-08
  • 2015-04-03
  • 1970-01-01
  • 1970-01-01
  • 2018-08-24
  • 1970-01-01
相关资源
最近更新 更多