I have a custom icon for a drawer and i want to place it vertically centred on activity with a shift of X axis -50%, so when the drawer opens the other 50% is visible.
what do i need:
- ImageView vertically centred and aligned to left
- Half of this imageView is visible ( translationX = -50% )
- When the drawer starts to slide, the rest of the imageView is visible
I have tried to do this, but the image is always cut when the drawer is dragged.
XML: MainActivity
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="-50dp"
android:src="@drawable/drawer_icon" />
</RelativeLayout>
<!-- The navigation drawer -->
<RelativeLayout
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="start">
<ListView
android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ff00"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
Once i drag the drawer i expect that the 50% hidden on left side start to be visible, so when the drawer is open the icon is 100% visible.