AmazingAvatar

AmazingAvatar

GitHub: https://github.com/hearsilent/AmazingAvatar

酷炫的 Android Avatar 搭配 CollaspingToolbarLayout 特效

螢幕截圖

Expanded

Collapsed

使用方法

範例 App

Get it on Google Play

客製化

將 Header View 改成想要的樣式

<android.support.design.widget.CollapsingToolbarLayout
    android:layout_width="match_parent"
    android:layout_height="224dp"
    app:contentScrim="@android:color/transparent"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:statusBarScrim="@android:color/transparent"
    app:titleEnabled="false">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_collapseMode="pin"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:gravity="center_vertical"
        app:layout_collapseMode="parallax"
        app:layout_collapseParallaxMultiplier="1">
        <android.support.v4.widget.Space
            android:id="@+id/space"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_marginLeft="32dp"/>
        <TextView
            android:id="@+id/toolbar_title"
            style="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:gravity="center_vertical"/>
    </LinearLayout>
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_collapseMode="parallax"
        app:layout_collapseParallaxMultiplier="1">
        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/imageView_avatar"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="?attr/actionBarSize"
            android:background="@drawable/avatar_background"
            android:contentDescription="@null"
            android:padding="1dp"/>
        <TextView
            android:id="@+id/textView_title"
            android:layout_width="wrap_content"
            android:layout_height="?attr/actionBarSize"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="130dp"
            android:gravity="center"
            android:maxLines="1"
            android:text="HearSilent"
            android:textColor="#FFF"
            android:textSize="24sp"/>
    </FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>

支援版本

Android GINGERBREAD 4.1+