L'effondrement de la Barre d'outils de mise en page avec le logo, le titre, les sous-titres dans la barre d'outils
Je veux faire, mais à un Effondrement de la barre d'outils de mise en page ou d'afficher le logo et le titre dans la barre d'outils après de défilement.
<!-- Toolbars -->
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<ImageView
android:id="@+id/background_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/background_1"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true"/>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<ImageView
android:id="@+id/avatar_image"
android:layout_width="@dimen/circular_image_avatar"
android:layout_height="@dimen/circular_image_avatar"
android:gravity="center"
android:scaleType="centerCrop"
android:src="@drawable/ic_placerholder"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:transitionName="image_toolbar"/>
<TextView
android:id="@+id/profile_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name title"
android:textAlignment="center"
android:layout_marginTop="@dimen/item_padding_top_bottom"
android:gravity="center"
style="@style/titleText_toolbar"
android:layout_below="@+id/avatar_image"
android:transitionName="title_toolbar"/>
<TextView
android:id="@+id/profile_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Subtitle"
android:textAlignment="center"
android:gravity="center"
style="@style/captionText_toolbar"
android:layout_below="@+id/profile_title" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin">
<!-- avatar image and title, subtitle -->
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
S'il vous plaît aider moi
- Ce code avez-vous essayé? Quels sont les problèmes que vous avez en cours d'exécution dans? Décrire et que l'on va (probablement) de l'aide.
- i.imgur.com/Yj7pe5Y.jpg i.imgur.com/AUVokgc.jpg i.imgur.com/dqWq3Fp.jpg Désolé je n'ai pas 10 réputation pour poster des images 🙁
- Le code n'est pas pertinent dans ce cas, je veux savoir comment faire
- salut @tonilopezmr pourriez-vous poster comment il a réalisé cela?
- découvrez ce github.com/saulmm/CoordinatorBehaviorExample
InformationsquelleAutor tonilopezmr | 2015-07-12
Vous devez vous connecter pour publier un commentaire.
J'ai preperead deux magnifique avatar effondrement des démos avec une approche qui n'utilise pas une coutume
CoordinatorLayoutBehavior
!Pour voir mes échantillons de code natif: "l'Effondrement de l'Avatar de la Barre d'outils de l'Échantillon"
De lire mon "l'Animation de l'Effondrement de la Barre d'outils Android" post sur le Support.
démo 1 démo 2
Au lieu d'utiliser une coutume
CoordinatorLayoutBehavior
- je utiliser unOnOffsetChangedListener
qui vient deAppBarLayout
.Démo 1
dans
updateViews
méthode avatar de modifier la taille et les changements d'avatar de la position X, Y de la traduction en première démo.pour trouver
avatarAnimateStartPointY
etavatarCollapseAnimationChangeWeight
(pour convertir général de décalage pour avatar animer offset):Démo 2
avatar changer sa taille et qu'animer déplacer à droite, à un moment avec le haut de la barre d'outils de texte est devenu un spectacle et se déplaçant vers la gauche.
Vous avez besoin de suivre les états:
TO_EXPANDED_STATE
changer,TO_COLLAPSED_STATE
changer,WAIT_FOR_SWITCH
.Créer des animations pour avatar sur l'état de l'interrupteur de changement:
Pour voir mes échantillons de code natif: "l'Effondrement de l'Avatar de la Barre d'outils de l'Échantillon"
lisse-app-bar-mise en page
voir Exemple
Installation