Reputation: 231
I am using following FAB library
https://github.com/futuresimple/android-floating-action-button.
and following this stackoverflow post Floating action button and white background to show overlay over screen.
I am using FloatingActionButton in Fragment using above mentioned post, but overlay does not come over action bar. Not able to find any solution to display overlay over full screen(including action bar)
Code 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>
Thanks in advance,
Pawan
Upvotes: 0
Views: 3311
Reputation: 21
You need to have the toolbar in your layout and have FrameLayout
as the parent. Then you can have a view with a transparent background in the layout that you can show and hide in the OnFloatingActionsMenuUpdateListener
interface methods.
Upvotes: 1
Reputation: 1850
I don't know your code, but I assume that you use a ActionbarActivity. The Actionbar used there does not belong to yout layout and therefore the FrameLayout does not draw on top of it.
Follow this Article to create a layout in which you have controll over the ActionBar (using Toolbar): http://javatechig.com/android/android-lollipop-toolbar-example
If that's not the Problem you could try to call View.bringToFront() on your Layout.
Upvotes: 1