在FAB阿尔法背景点击 [英] Alpha background on FAB clicked
问题描述
我使用该库 https://github.com/futuresimple/android-浮动作按钮创建晶圆厂按钮,工作pretty的好。我试了几个库,但没有使用在大多数应用程序,该工厂被点击整个应用程序的背景下,当一个工厂(如守,收件箱或谷歌应用程序)使用的效果becames半透明的白色或黑色的,它依赖。我找不到任何办法做到这一点。是否有可能有一个例子或类似的东西做这样的效果呢?你可以明白我的意思在该图像:
I'm using the library 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,但似乎不工作,因为我want.Seems是不重叠的全部观点,但只是颜色它想要的东西。
this is my layout.xml but seems not working at all as i want.Seems that not overlap the entire view but just colors what it wants..
推荐答案
喜欢你的问题...
这个库将不会允许ü设置添加按钮点击事件,您可能需要更改库$ C $下你自己的,用这样的想法: 使用Relatie或的FrameLayout,并添加黑色的背景或形象背后FAB。
This library won't allow u to set add button click event, you may have to change library code for your own, use this idea: Use Relatie or framelayout and add that black background or image behind FAB.
现在的库班FloatingActionsMenu.class找到并评论此code:
Now in library class FloatingActionsMenu.class find and comment this code:
//mAddButton.setOnClickListener(new OnClickListener()
//{
// @Override
// public void onClick(View v)
// {
// toggle();
// }
//});
然后在类中添加此方法,
Then add this method in that class,
public void setAddButtonClickListener(OnClickListener listener)
{
mAddButton.setOnClickListener(listener);
}
定义点击监听器在你喜欢的活动。
Define click listener in your activity like
OnClickListener listener = new OnClickListener()
{
@Override
public void onClick(View v)
{
if (floatingActionMenuButton.isExpanded())
{//make the background visible
}
else
{//make the background invisible
}
floatingActionMenuButton.toggle();
}
};
和它传递给FAB
floatingActionMenuButton.setAddButtonClickListener(listener);
生成库和项目,希望这将有助于!
Build library and project, Hope this will help!
这篇关于在FAB阿尔法背景点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!