简体   繁体   English

设置浮动动作按钮的位置[在浮动动作菜单中]

[英]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]? 在浮动动作菜单[FAM]中是否有设置浮动动作按钮[FAB]的经验?

Due to the screen size doesn't fit the amount of FAB [14], so I need few FABs on second column/ other position. 由于屏幕尺寸不适合FAB的数量[14],因此我在第二列/其他位置上需要很少的FAB。 Image Here 图片在这里

This is my case: final com.github.clans.fab.FloatingActionMenu famLeft = (com.github.clans.fab.FloatingActionMenu) findViewById(R.id.menu_labels_left); 这是我的情况:最终的com.github.clans.fab.FloatingActionMenu famLeft =(com.github.clans.fab.FloatingActionMenu)findViewById(R.id.menu_labels_left);

for (int i = 13; i >= 0; i--) { 为(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 请在github上检查此库

https://github.com/Clans/FloatingActionButton 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. 或者我建议您将FAB放置在xml中的任何位置。 and handle the visibility of each of the FAB from your program. 并处理程序中每个FAB的可见性。

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. 也许您应该在单列中滚动FAB,但我不确定如何开发这一列,但我认为这是最好的方法。

Happy Coding! 编码愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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