我的问题与这个有关。
当我打开导航抽屉时,浮动按钮在其顶部但必须在其下方。
我尝试这样做:
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
Log.i(TAG , " inner onDrawerSlide");
super.onDrawerSlide(drawerView, slideOffset);
fabButton.setAlpha(25);
float alpha = 0.2f;
AlphaAnimation alphaUp = new AlphaAnimation(alpha, alpha);
alphaUp.setFillAfter(true);
fabButton.startAnimation(alphaUp);
syncState();
}
并且就像这样:
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerClosed(view);
invalidateOptionsMenu();
fabButton.setAlpha(255);
syncState();
}
没什么方法对我有用。有什么解决方案吗?
我的布局:
<mobapply.freightexchange.customviews.FragmentNavigationDrawer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<!-- The ActionBar -->
<include
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- The main content view -->
<FrameLayout
android:id="@+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/lvDrawer"
android:layout_width="match_parent"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:background="#FFFFFF"
android:cacheColorHint="@android:color/transparent"
/>
FragmentNavigationDrawer是自定义的DrawerLayout
Button
在DrawerLayout
中的位置,而不是alpha本身。 - Bartek Lipinski