I'm trying to make something similar to the example seen here , only that the CircleImageView
is inside toolbar already. What I want to achieve is to narrow down the toolbar and make the image smaller as I scroll down.
I tried following multiple tutorials on this case but still didn't manage to get it working.
activity_settings.xml
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main_collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:id="@+id/btn_back"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginLeft="-16dp"
android:padding="16dp"
app:srcCompat="@drawable/ic_arrow_back_white" />
<TextView
android:id="@+id/textview_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_toRightOf="@id/btn_back"
android:text="@string/settings"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
tools:ignore="RtlHardcoded" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_below="@id/textview_title"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:src="@drawable/ic_profile_placeholder"
app:civ_border_color="@color/white"
app:civ_border_width="2dp"
app:civ_border_overlay="true"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/appbar"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
The FrameLayout
gets replaced with a separate fragment which contains PreferenceScreen
with PreferenceCategory, EditTextPreference and Preference
inside it. That piece of fragment itself is scrollable, I know however that FrameLayout, which is initially present in activity and replaced onCreate
, is not. Could that be the problem? If so, is there a way to keep the fragment injection and still get it to work or does it all have to be in one layout file?
Any help appreciated!
replace this in toolbar
<android.support.v7.widget.Toolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/appColor"
android:elevation="6dp"
android:minHeight="?android:attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" >
....
</android.support.v7.widget.Toolbar>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.