0

アプリにこの循環メニューを使用しています。 https://github.com/oguzbilgener/CircularFloatingActionMenu 動作しています。しかし、Navigation Drawer を開くと。このメニューは手前にあります。メニューをナビゲーション ドロワーに戻すにはどうすればよいですか。

ナビゲーション ドロワーを前面に移動するにはどうすればよいですか?

ここに画像の説明を入力

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();
        }
    }
}
4

1 に答える 1

0

これは私の回答 hereと非常によく似ていますが、FloatingActionButtonインスタンス化にわずかな変更があるだけです。

ライブラリ コードは、ボタンとメニューがアクティビティのコンテンツ ビューとその中のすべての上に表示されることを前提としています。クラスにコンテナー ViewGroup メンバーを追加FloatingActionButtonすると、代わりに子 ViewGroup を親に指定できます。FloatingActionButton次の変更は、メニューでa を使用した場合にのみ機能することに注意してください。

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();
        ...
    }
    ...
}
于 2015-01-02T19:00:28.720 に答える