I'm using the library https://github.com/futuresimple/android-floating-action-button https://github.com/futuresimple/android-floating-action-button to create the fab buttons that works pretty well. I tried several libraries but none use the effect used in most application with a fab (or Google apps like keep, inbox) that when the fab is clicked the background of entire application becames semi-transparent white or black, it depends. I can't find any way to do it. Is it possible have an example or something like that to do this kind of effect? You can see what i mean in this image:
半黑背景
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/semi_white_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white_semi_transparent"
android:visibility="gone" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/listFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/content_frame"
android:visibility="gone" >
<TextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cabinet_color"
android:fontFamily="sans-serif"
android:gravity="center_vertical"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:textColor="#fff"
android:textSize="17sp"
android:visibility="gone" />
<android.support.v7.widget.RecyclerView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/status"
android:clipToPadding="false"
android:scrollbars="vertical" />
<LinearLayout
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >
<ImageView
android:id="@+id/emptyImage"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
android:scaleType="fitXY"
android:src="?empty_image" />
<TextView
android:id="@+id/emptyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:lineSpacingMultiplier="1.4"
android:paddingBottom="16dp"
android:text="@string/no_files"
android:textColor="?empty_text"
android:textSize="22sp" />
</LinearLayout>
</RelativeLayout>
<ProgressBar
android:id="@android:id/progress"
style="?android:progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminateOnly="true" />
</RelativeLayout>
这是我的layout.xml,但似乎根本无法按照我想要的方式工作。似乎没有重叠整个视图,而只是为它想要的颜色着色。
我发现这是我认为最简单的解决方案,而且效果很好:
fam.setOnFloatingActionsMenuUpdateListener(new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() {
@Override
public void onMenuExpanded() {
dimmedBackground.setVisibility(View.VISIBLE);
}
@Override
public void onMenuCollapsed() {
dimmedBackground.setVisibility(View.GONE);
}
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)