2014-12-26 2 views
0

Я использую это круговое меню для своего приложения. https://github.com/oguzbilgener/CircularFloatingActionMenu Он работает. Но когда я открою свой навигационный ящик. Это меню находится спереди. Как я могу заставить меню вернуться в навигационный ящик.Как перенести мой навигационный ящик на передний план?

Как я могу принести свой навигационный ящик на передний план?

enter image description here

public class Home extends MainActivity implements OnClickListener 
{ 


    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     this.application = (Remtt) this.getApplication(); 
     this.preferences = this.application.getPreferences(); 
     super.onCreate(savedInstanceState); 
     this.checkOnCreate(); 

      int redActionButtonSize = getResources().getDimensionPixelSize(R.dimen.red_action_button_size); 
      int redActionButtonMargin = getResources().getDimensionPixelOffset(R.dimen.action_button_margin); 
      int redActionButtonContentSize = getResources().getDimensionPixelSize(R.dimen.red_action_button_content_size); 
      int redActionButtonContentMargin = getResources().getDimensionPixelSize(R.dimen.red_action_button_content_margin); 
      int redActionMenuRadius = getResources().getDimensionPixelSize(R.dimen.red_action_menu_radius); 
      int blueSubActionButtonSize = getResources().getDimensionPixelSize(R.dimen.blue_sub_action_button_size); 
      int blueSubActionButtonContentMargin = getResources().getDimensionPixelSize(R.dimen.blue_sub_action_button_content_margin); 

      ImageView fabIconStar = new ImageView(this); 
      fabIconStar.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_headphones)); 

      FloatingActionButton.LayoutParams starParams = new FloatingActionButton.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); 
      starParams.setMargins(redActionButtonMargin, redActionButtonMargin, redActionButtonMargin, redActionButtonMargin); 
      fabIconStar.setLayoutParams(starParams); 

      FloatingActionButton.LayoutParams fabIconStarParams = new FloatingActionButton.LayoutParams(redActionButtonContentSize, redActionButtonContentSize); 
      fabIconStarParams.setMargins(redActionButtonContentMargin, redActionButtonContentMargin, redActionButtonContentMargin, redActionButtonContentMargin); 

      FloatingActionButton leftCenterButton = new FloatingActionButton.Builder(this).setContentView(fabIconStar, fabIconStarParams).setBackgroundDrawable(R.drawable.button_action_red_selector).setPosition(FloatingActionButton.POSITION_TOP_CENTER).setLayoutParams(starParams).build(); 

      // Set up customized SubActionButtons for the right center menu 
      SubActionButton.Builder lCSubBuilder = new SubActionButton.Builder(this); 
      lCSubBuilder.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_action_blue_selector)); 

      FrameLayout.LayoutParams blueContentParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); 
      blueContentParams.setMargins(blueSubActionButtonContentMargin, blueSubActionButtonContentMargin, blueSubActionButtonContentMargin, blueSubActionButtonContentMargin); 
      lCSubBuilder.setLayoutParams(blueContentParams); 
      // Set custom layout params 
      FrameLayout.LayoutParams blueParams = new FrameLayout.LayoutParams(blueSubActionButtonSize, blueSubActionButtonSize); 
      lCSubBuilder.setLayoutParams(blueParams); 

      ImageView lcIcon1 = new ImageView(this); 
      ImageView lcIcon2 = new ImageView(this); 
      ImageView lcIcon3 = new ImageView(this); 
      ImageView lcIcon4 = new ImageView(this); 
      ImageView lcIcon5 = new ImageView(this); 
      ImageView lcIcon6 = new ImageView(this); 
      ImageView lcIcon7 = new ImageView(this); 
      ImageView lcIcon8 = new ImageView(this); 
      ImageView lcIcon9 = new ImageView(this); 

      lcIcon1.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 
      lcIcon2.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 
      lcIcon3.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 
      lcIcon4.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 
      lcIcon5.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_headphones)); 
      lcIcon6.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 
      lcIcon7.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 
      lcIcon8.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 
      lcIcon9.setImageDrawable(getResources().getDrawable(R.drawable.anim)); 

      // Build another menu with custom options 
      FloatingActionMenu leftCenterMenu = new FloatingActionMenu.Builder(this).addSubActionView(lCSubBuilder.setContentView(lcIcon1, blueContentParams).build()).addSubActionView(lCSubBuilder.setContentView(lcIcon2, blueContentParams).build()).addSubActionView(lCSubBuilder.setContentView(lcIcon3, blueContentParams).build()).addSubActionView(lCSubBuilder.setContentView(lcIcon4, blueContentParams).build()).addSubActionView(lCSubBuilder.setContentView(lcIcon5, blueContentParams).build()) 
        .addSubActionView(lCSubBuilder.setContentView(lcIcon6, blueContentParams).build()).addSubActionView(lCSubBuilder.setContentView(lcIcon7, blueContentParams).build()).addSubActionView(lCSubBuilder.setContentView(lcIcon8, blueContentParams).build()).addSubActionView(lCSubBuilder.setContentView(lcIcon9, blueContentParams).build()).setRadius(redActionMenuRadius).setStartAngle(0).setEndAngle(360).attachTo(leftCenterButton).build(); 
     } 
    } 
} 
+0

использовать метод bringtofront() или использовать framelayout. – Yogendra

+1

Измените библиотеку. Измените метод FloatingActionMenu.getActivityContentView() и верните группу представлений, в которой содержится ваш контент активности - тот, который определен внутри тегов DrawerLayout в xml. – Athena

+0

http://stackoverflow.com/questions/27067440/my-fragment-hides-the-navigation-drawer –

ответ

0

Это очень похоже на my answer here, лишь с незначительными изменениями в FloatingActionButton конкретизации.

В библиотечном коде предполагается, что кнопка и меню будут отображаться поверх содержимого содержимого Activity и все в нем. Добавление члена ViewGroup контейнера в классе FloatingActionButton позволяет нам вместо этого указать дочернюю группу ViewGroup. Обратите внимание, что следующие изменения будут работать, только если в меню используется FloatingActionButton.

Дополнения к FloatingActionButton класса:

public class FloatingActionButton extends FrameLayout { 
    ... 
    private ViewGroup containerView; 
    ... 
    public FloatingActionButton(Activity activity, 
           LayoutParams layoutParams, 
           int theme, 
           Drawable backgroundDrawable, 
           int position, 
           View contentView, 
           FrameLayout.LayoutParams contentParams  
           // Note the addition of the following 
           // constructor parameter here 
           , ViewGroup containerView) { 
     ... 
     setClickable(true); 

     // This line is new. The rest of the constructor is the same. 
     this.containerView = containerView;  

     attach(layoutParams); 
    } 
    ... 
    public View getActivityContentView() { 
     if(containerView == null) { 
      return ((Activity)getContext()) 
       .getWindow().getDecorView().findViewById(android.R.id.content); 
     } else { 
      return containerView; 
     } 
    } 

    public ViewGroup getContainerView() { 
     return containerView; 
    } 

    // The following setter is not strictly necessary, but may be of use 
    // if you want to toggle the Button's and Menu's z-order placement 
    public void setContainerView(ViewGroup containerView) { 
     this.containerView = containerView; 
    } 
    ... 
    public static class Builder { 
     ... 
     private ViewGroup containerView; 
     ... 
     public Builder setContainerView(ViewGroup containerView) { 
      this.containerView = containerView; 
      return this; 
     } 

     public FloatingActionButton build() { 
      return new FloatingActionButton(activity, 
              layoutParams, 
              theme, 
              backgroundDrawable, 
              position, 
              contentView, 
              contentParams, 
              // New argument 
              containerView); 
     } 
    } 
    ... 
} 

И изменения к FloatingActionMenu класса:

public class FloatingActionMenu { 
    ... 
    public View getActivityContentView() { 
     if(mainActionView instanceof FloatingActionButton && 
      ((FloatingActionButton) mainActionView).getContainerView() != null) { 
      return ((FloatingActionButton) mainActionView).getContainerView(); 
     } else { 
      return ((Activity)mainActionView.getContext()) 
       .getWindow().getDecorView().findViewById(android.R.id.content); 
     } 
    } 
    ... 
} 

Тогда, предполагая, что ваш макет активность подобен:

<android.support.v4.widget.DrawerLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    ...> 

    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
    ... 
</android.support.v4.widget.DrawerLayout> 

В вашей деятельности Home вы должны создать и создать экземпляр leftCenterButton следующим образом:

public class Home extends Activity implements OnClickListener { 
    ... 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     ... 
     FrameLayout container = (FrameLayout) findViewById(R.id.container); 

     FloatingActionButton leftCenterButton = new FloatingActionButton.Builder(this) 
      .setContentView(fabIconStar, null) 
      .setBackgroundDrawable(R.drawable.ic_launcher) 
      .setPosition(FloatingActionButton.POSITION_TOP_CENTER) 
      .setLayoutParams(starParams) 
      // The new method call is added here 
      .setContainerView(container) 
      .build(); 
     ... 
    } 
    ... 
} 
Смежные вопросы