我的問題是關於this之一。材質設計:如何爲Android設置透明度浮動操作按鈕
當我打開NavigationDrawer時,浮動按鈕位於頂部,但必須位於下方。
我嘗試做這樣的:
@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
是的,謝謝你,幫助。但是問題仍然存在 - 即使我將0.1f設置爲透明度,但顯示在導航抽屜的上方。必須找到更好的解決方案... –
所以問題是你的'Button'在你的'DrawerLayout'中的定位,而不是與alpha本身 –
是的,你是對的 - 你知道如何以編程方式嗎? –