简体   繁体   中英

Set Position of Floating Action Button [in Floating Action Menu]

Is there any one experience on setting position of floating action button [FAB] that put in floating action menu [FAM]?

Due to the screen size doesn't fit the amount of FAB [14], so I need few FABs on second column/ other position. Image Here

This is my case: final com.github.clans.fab.FloatingActionMenu famLeft = (com.github.clans.fab.FloatingActionMenu) findViewById(R.id.menu_labels_left);

for (int i = 13; i >= 0; i--) {

com.github.clans.fab.FloatingActionButton fabLeft = new com.github.clans.fab.FloatingActionButton(this);

String uri = "@drawable/" + hr_logo[i];

int imageResource = getResources().getIdentifier(uri, null, getPackageName());

Bitmap bm = BitmapFactory.decodeResource(getResources(), imageResource);

bm = Bitmap.createScaledBitmap(bm, dpToPx(40), dpToPx(40), true);

fabLeft.setImageBitmap(bm);

fabLeft.setLabelText(sub_cat_name[i]);

fabLeft.setColorNormal(R.color.WetAsphalt);

famLeft.addMenuButton(fabLeft);

fabLeft.setButtonSize(FloatingActionButton.SIZE_MINI);

fabLeft.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
    }

});

}

Do check this library on github

https://github.com/Clans/FloatingActionButton

you might get a solution here. or simply a work around may be.

or rather I will suggest you to position your FABs in xml wherever you want. and handle the visibility of each of the FAB from your program.

and may be you should go for scrolling FABs in a single column, I am not sure how to develop this one, I think that would be the best approach though.

Happy Coding!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM