تابستون داره تموم میشه ها، فرصت‌ها محدودن کلی آفر جذاب در کمپین تابستون🔥👇
۰ ثانیه
۰ دقیقه
۰ ساعت
۵ محسن موسوی
مشکل در نمایش کامل toolbar
جامعه جاوا (اندروید) ایجاد شده در ۲۳ تیر ۱۴۰۱

سلام.من تمام مراحل رو پیش رفتم تا جایی که toolbar مربوط به هر فراگمنت رو جدا می‌کنیم.toolbar رو از صفحه main کتا کردم و درون فراگمنت قرار دادم و...کاملا مثل آموزش.اما وقتی اجرا می‌کردم طول بار کامل نشان داده نمی‌شد.

بعد درون کلاس فراگمنت مربوط به صفحه طول بار را تعریف کردم و setsuportactionbar رو هم زدم وقتی اجرا کردم،طول بار نصفه نشان داده می‌شد.

میشه راهنماییم کنید

هم از toolbar استفاده کردم،هم از material tool bar اما فرقی نداشت

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:liftOnScroll="true"
        android:orientation="vertical"
        >
        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/fragment_Main_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:titleTextColor="@color/white"
            app:layout_scrollFlags="scroll|enterAlways"
            />
    com.google.android.material.appbar.AppBarLayout>
    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <include layout="@layout/layout_inputfragment_main"/>
            <include layout="@layout/layout_inputfragment_main"/>
            <include layout="@layout/layout_inputfragment_main"/>
            <include layout="@layout/layout_inputfragment_main"/>
            <include layout="@layout/layout_inputfragment_main"/>
            <include layout="@layout/layout_inputfragment_main"/>
            <include layout="@layout/layout_inputfragment_main"/>
        LinearLayout>
    androidx.core.widget.NestedScrollView>
androidx.coordinatorlayout.widget.CoordinatorLayout>


Fragment Main

Toolbar toolbar =view.findViewById(R.id.fragment_Main_toolbar);
AppCompatActivity ac = (AppCompatActivity) getActivity();
ac.setSupportActionBar(toolbar);



محسن موسوی ۲۳ تیر ۱۴۰۱، ۰۶:۴۲

سلام امیدوارم عالی باشید اتربیوت زیر رو از AppbarLayout بردارید فکر میکنم مشکلتون حل میشه

android:orientation="vertical"

اگر نشد لطفا بقیه کد‌های xml هم ارسال کنید

پوریا شفیعی ۲۳ تیر ۱۴۰۱، ۱۴:۲۱

متاسفانه درست نشد

همه کد‌های xml مربوط به فرگمنت اصلی رو ارسال کردم.منظور شما کدام xml است؟

این هم کد بخش خود Activity

<FrameLayout 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"
    tools:context=".MainActivity">
    <FrameLayout
        android:id="@+id/main_framefragment"
        android:name="com.example.material_design.Fragment_Main"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"/>
FrameLayout>


محسن موسوی ۲۵ تیر ۱۴۰۱، ۰۸:۱۳

خیلی متاسفم

توی بخش activity main طول و ارتفاع framelayout رو روی wrap_content گذاشتم.

اصلا حواسم نبوده این اشتباه رو کردم?

محسن موسوی ۲۵ تیر ۱۴۰۱، ۱۱:۵۲

خوشحالم مشکلتون حل شده

هر چه بیشتر اشتباه کنین و حلش کنین بیشتر یاد میگیرین پس نگران نباشین اشتباه قسمت مهمی از مسیر یادگیری هست


بهترین پاسخ
پوریا شفیعی ۲۵ تیر ۱۴۰۱، ۱۳:۳۲