I am build an Application which need and image to slide in and out according to the movement of the DrawerLayout
. Like, When we open
drawer the image shrinks a little bit and when we close
the drawer then the image regain its size.
I have this image in the Toolbar
.
My Code :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
android:background="@android:color/transparent"
android:paddingLeft="10dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/left"
android:layout_centerVertical="true"
android:id="@+id/img"/>
</RelativeLayout>
I have tried doing this by adding the below code
mImage.setAnimation(AnimationUtils.loadAnimation(context,R.anim.animation));
in the onDrawerClosed(View view)
and onDrawerOpened(View drawerView)
But these are not useful as I need to have this animation or transition syncing with the drawer movement.
If Anybody have any suggestions please share.