android - How to get the right Height for toolBar in a fragment? - Stack Overflow

this is my xml code in main activity for fragment<FrameLayoutandroid:id="@+idframe"androi

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 ?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744309973a4567899.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信