admin管理员组

文章数量:1405561

this is my xml code in main activity for fragment

 <FrameLayout
    android:id="@+id/frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

and this is the appBar layout in fragment

    <com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="parent"
    android:background="@color/white"
    >

    <com.google.android.material.appbar.MaterialToolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:layout_constraintTop_toTopOf="parent"
        >

        <ImageView
            android:id="@+id/toolBarImage"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginStart="30dp"
            android:background="@drawable/button_box"
            android:clipToOutline="true"
            android:scaleType="centerCrop"
            android:src="@mipmap/boy3" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="20dp"
            android:ellipsize="end"
            android:maxWidth="150dp"
            android:maxLines="1"
            android:text="User Name"
            android:textSize="16sp"
            android:textStyle="bold" />
    </com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>

but the height is much lower than expected this is a pic image of fragment in app. tested virtual device is pixel 7a. even in real device I am facing same problem. can you help me to fix it ?

本文标签: androidHow to get the right Height for toolBar in a fragmentStack Overflow