浮动动作按钮和全屏幕白色背景
问题描述:
我正在使用以下FAB库012 https://github.com/futuresimple/android-floating-action-button。
并在此之后的stackoverflow后Floating action button and white background显示叠加在屏幕上。浮动动作按钮和全屏幕白色背景
我在使用上面提到的帖子的片段中使用FloatingActionButton,但覆盖不会超过操作栏。 没能找到任何解决方案在整个屏幕来显示覆盖(包括行动起来吧)
代码 Fragment.java
final FrameLayout fl = FrameLayout)view.findViewById(R.id.floatingcontainer);
final FloatingActionsMenu fam = (FloatingActionsMenu) fl.findViewById(R.id.multiple_actions);
fam.setOnFloatingActionsMenuUpdateListener(new OnFloatingActionsMenuUpdateListener() {
@Override
public void onMenuExpanded() {
// TODO Auto-generated method stub
fl.setBackgroundColor(Color.parseColor("#c0ffffff"));
}
@Override
public void onMenuCollapsed() {
// TODO Auto-generated method stub
fl.setBackgroundColor(Color.TRANSPARENT);
}
});
fl.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// ignore all touch events
if(fam.isExpanded()){
fam.collapse();
return true;
}
return false;
}
});
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res/com.yourapp.data"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
//some previous code
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/floatingcontainer"
android:clickable="false" >
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/multiple_actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="66dp"
fab:fab_addButtonColorNormal="@color/orange"
fab:fab_addButtonColorPressed="@color/orange_pressed"
fab:fab_labelStyle="@style/menu_labels_style" >
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/action_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_icon="@drawable/menu1"
fab:fab_colorNormal="@color/orange"
fab:fab_colorPressed="@color/orange_pressed"
fab:fab_title="Menu 1" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/action_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_icon="@drawable/menu2"
fab:fab_colorNormal="@color/orange"
fab:fab_colorPressed="@color/orange_pressed"
fab:fab_title="Menu 2" />
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</FrameLayout>
提前
谢谢,
Pawan
答
我不知道你的代码,但我假设你使用了一个ActionbarActivity。在那里使用的Actionbar不属于你的布局,因此FrameLayout不会在其上绘制。
按照本文创建中,你必须控制研究在动作条(使用工具栏)布局:http://javatechig.com/android/android-lollipop-toolbar-example
如果这不是你可以尝试在你的布局调用View.bringToFront()的问题。
答
你需要在你的布局中有工具栏,并有FrameLayout
作为父级。然后,您可以在布局中使用透明背景来显示和隐藏接口方法中的视图。
请添加您使用的代码。 – 2015-04-05 13:01:36