J'utilise actuellement la mise en page CollapsingToolbar dans la partie supérieure de ma mise en page. Je veux recopier une partie particulière (LinearLayout seulement) et garder la barre d'outils fixe sur le dessus. J'ai été en mesure de corriger la position de la barre d'outils sur un autre projet et de l'empêcher de s'effondrer. Cependant, pour une raison quelconque, je ne suis pas en mesure de corriger la position de ma barre d'outils. Toute aide serait appréciée. Voici le XML de la mise en page:Android - Impossible de fixer la barre d'outils dans une mise en page Collapsing barre d'outils
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/profile_coordinate_layout"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_gravity="fill_vertical"
android:fitsSystemWindows="true"
app:layout_collapseMode="pin"
app:expandedTitleMarginStart="?actionBarSize"
app:contentScrim="?colorPrimary"
>
<!--|||||||||||||||||||||||||||||||||||||||||||||||||-->
<!--|||||||||||||||Collection Profile and about||||||-->
<!--|||||||||||||||||||||||||||||||||||||||||||||||||-->
<LinearLayout
android:id="@+id/ll_header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?actionBarSize"
android:orientation="vertical"
app:layout_collapseMode="pin"
android:background="@drawable/gradient_feed_bg"
>
<include
layout="@layout/item_collection_profile" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@drawable/dark_primary_no_radius"
app:layout_collapseMode="pin"
android:elevation="@dimen/margin_4dp"
>
<include layout="@layout/action_bar_collection_profile"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
></android.support.v4.view.ViewPager>
</android.support.design.widget.CoordinatorLayout>
Je charge un autre fragment sur ViewPager. et j'utilise le code suivant pour charger la barre d'outils.
findViewById(R.id.toolbar). setBackgroundResource(R.drawable.dark_primary_no_radius);
setSupportActionBar((android.support.v7.widget.Toolbar)findViewById(R.id.toolbar));
Et voici MISE À JOUR le résultat:
Comme vous pouvez le voir, dans la deuxième image, barre d'outils sont effondrés sur le dessus. Toute aide sera grandement appréciée.
Merci.
je l'ai fait. Cependant, la barre d'outils est toujours en train de s'effondrer. –
merci l'homme, il a résolu mon problème, la barre d'outils est épinglée sur le dessus cependant, il y a un espace vide vide de taille de la barre d'outils sur le fond de la mise en page. Comment puis-je résoudre ce problème? –
si j'utilise l'application: layout_scrollFlags = « scroll | exitUntilCollapsed », alors j'ai une place vide au fond, si j'utilise l'application: layout_scrollFlags = « scroll | enterAlways », puis la barre d'outils n'est pas fixée sur le dessus. –