【问题标题】:FrameLayout width is not equal to its parent which is a ToolbarFrameLayout 宽度不等于其父工具栏
【发布时间】:2018-01-28 12:15:19
【问题描述】:

我现在在工具栏内有一个框架布局,问题是我设置框架布局宽度以匹配专利,但它不会等于它,而工具栏是全长 我的代码如下

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ecbclass.user_activity.Home">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/app_title_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:text="ECB Class"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#FFF"
                android:textStyle="bold" />

            <android.support.v7.widget.SearchView
                android:id="@+id/search_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center_vertical"
                android:elevation="5dp"
                android:hapticFeedbackEnabled="true"
                android:layoutDirection="rtl">

            </android.support.v7.widget.SearchView>

        </FrameLayout>
    </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_home" />

请告诉我解决这个问题的方法

【问题讨论】:

    标签: android width android-toolbar android-framelayout


    【解决方案1】:

    Toolbar 中添加几行(contentInsetLeftcontentInsetStart)就完成了:-

    <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            android:contentInsetLeft="0dp"
            android:contentInsetStart="0dp"
            app:contentInsetLeft="0dp"
            app:contentInsetStart="0dp" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-15
      • 2011-09-13
      • 2021-10-30
      • 1970-01-01
      • 2023-03-26
      • 2013-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多