Android 安卓-设置抽屉图标半可见

Android 安卓-设置抽屉图标半可见,android,drawer,Android,Drawer,我有一个抽屉的自定义图标,我想将其垂直放置在活动中心,X轴移动-50%,因此当抽屉打开时,其他50%可见 我需要什么: ImageView垂直居中并与左侧对齐 此imageView的一半是可见的translationX=-50% 当抽屉开始滑动时,imageView的其余部分可见 我曾尝试过这样做,但当抽屉被拖动时,图像总是被剪切 XML:main活动 <android.support.v4.widget.DrawerLayout xmlns:android="http://sc

我有一个抽屉的自定义图标,我想将其垂直放置在活动中心,X轴移动-50%,因此当抽屉打开时,其他50%可见

我需要什么:

ImageView垂直居中并与左侧对齐 此imageView的一半是可见的translationX=-50% 当抽屉开始滑动时,imageView的其余部分可见 我曾尝试过这样做,但当抽屉被拖动时,图像总是被剪切

XML:main活动

 <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>

一旦我拖动抽屉,我希望左侧隐藏的50%开始可见,因此当抽屉打开时,图标100%可见。

尝试从imageView中删除android:layout_marginLeft=-50dp代码行。

请显示一些代码。好的-现在屏幕左侧有这个半图标。当抽屉从左侧进入时,图标将被完全覆盖。你想做什么呢?我想让ImageView图标与抽屉一起移动,这样当抽屉完全打开时,我就能看到完整的图像。所以一起移动加上额外的移动来显示实际隐藏的图像的一半?是的,如果我最初将图像移动到-50%,当我拖动时,我想看到剩下的50%覆盖在抽屉上