2015-04-05 43 views
0

我正在使用以下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

+0

請添加您使用的代碼。 – 2015-04-05 13:01:36

回答

1

我不知道你的代碼,但我假設你使用了一個ActionbarActivity。在那裏使用的Actionbar不屬於你的佈局,因此FrameLayout不會在其上繪製。

按照本文創建中,你必須控制研究在動作條(使用工具欄)佈局:http://javatechig.com/android/android-lollipop-toolbar-example

如果這不是你可以嘗試在你的佈局調用View.bringToFront()的問題。

1

你需要在你的佈局中有工具欄,並有FrameLayout作爲父級。然後,您可以在佈局中使用透明背景來顯示和隱藏接口方法中的視圖。