Android 动画无法正确打开菜单
我有一个问题,我的菜单在应用程序中以一种稍微奇怪的方式打开,我在下面放了一个屏幕截图来显示我的意思。正如您所看到的,菜单正在显示并移动片段。我希望它出现在现有片段的顶部。我用一个动画来展示这个 动画代码如下所示: 公共静态空白打开(最终上下文、最终相对上下文布局){ } 这将调用anim文件夹中的xml文件,如下所示:Android 动画无法正确打开菜单,android,xml,animation,android-fragments,Android,Xml,Animation,Android Fragments,我有一个问题,我的菜单在应用程序中以一种稍微奇怪的方式打开,我在下面放了一个屏幕截图来显示我的意思。正如您所看到的,菜单正在显示并移动片段。我希望它出现在现有片段的顶部。我用一个动画来展示这个 动画代码如下所示: 公共静态空白打开(最终上下文、最终相对上下文布局){ } 这将调用anim文件夹中的xml文件,如下所示: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.andro
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:fromXDelta="0"
android:fromAlpha="0.0"
android:toAlpha="0.3"
android:toXDelta="+50%p"/>
</set>
<RelativeLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
<ListView
android:id="@+id/listMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:choiceMode="singleChoice"
android:divider="@android:color/darker_gray"
android:dividerHeight="1dp"
android:listSelector="@android:color/darker_gray"/>
<RelativeLayout
android:id="@+id/fragmentspace"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:fromAlpha="0.3"
android:fromXDelta="+50%p"
android:toAlpha="0.0"
android:toXDelta="0"/>
</set>
close代码调用另一个xml文件,该文件也位于anim文件夹中,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:fromXDelta="0"
android:fromAlpha="0.0"
android:toAlpha="0.3"
android:toXDelta="+50%p"/>
</set>
<RelativeLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
<ListView
android:id="@+id/listMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:choiceMode="singleChoice"
android:divider="@android:color/darker_gray"
android:dividerHeight="1dp"
android:listSelector="@android:color/darker_gray"/>
<RelativeLayout
android:id="@+id/fragmentspace"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:fromAlpha="0.3"
android:fromXDelta="+50%p"
android:toAlpha="0.0"
android:toXDelta="0"/>
</set>
那么您想在地图上显示“新预订”列表视图?还是“绿色新港”列表视图应该位于其他位置?谢谢您的回复!我想让listview覆盖地图,我会假设问题的根源在于相对布局,就好像你移动了一个子元素,其余的都会移动一样。看起来您并不是在使用抽屉布局来创建导航抽屉,而导航抽屉可能适合您的目的。我还发现了一个关于如何编辑默认动画时间的博客: