Java Code Examples for com.google.android.material.floatingactionbutton.FloatingActionButton#setSize()

The following examples show how to use com.google.android.material.floatingactionbutton.FloatingActionButton#setSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SatelliteMenuView.java    From CrazyDaily with Apache License 2.0 6 votes vote down vote up
public void setImgRes(ImgResEntity entity) {
    final Context context = getContext();
    final int dp_6 = dp2px(context, 6);
    final int dp_3 = dp2px(context, 3);
    FloatingActionButton fab = new FloatingActionButton(context);
    fab.setPadding(dp_6, dp_6, dp_6, dp_6);
    fab.setElevation(dp_3);
    fab.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    fab.setSize(FloatingActionButton.SIZE_MINI);
    fab.setBackgroundTintList(ColorStateList.valueOf(entity.color));
    fab.setImageResource(entity.res);
    fab.setUseCompatPadding(true);
    final int size = (int) (SIZE * BUTTON_RATIO);
    LayoutParams params = new LayoutParams(size, size);
    params.gravity = Gravity.END | Gravity.BOTTOM;
    addView(fab, params);
    mButtonView = fab;
    mButtonView.setOnClickListener(v -> {
        if (isOpen) {
            close();
        } else {
            show();
        }
    });
}
 
Example 2
Source File: FloatingActionButtonActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
public static ViewAction setSize(@FloatingActionButton.Size final int size) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(FloatingActionButton.class);
    }

    @Override
    public String getDescription() {
      return "Sets FloatingActionButton size";
    }

    @Override
    public void perform(UiController uiController, View view) {
      final FloatingActionButton fab = (FloatingActionButton) view;
      fab.setSize(size);
    }
  };
}
 
Example 3
Source File: ThreadDetailActivity.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_thread_detail);
    mRootView = findViewById(R.id.main_activity_root_view);
    mMainFrameContainer = findViewById(R.id.main_frame_container);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.appbar_layout);
    mQuickReply = findViewById(R.id.quick_reply);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    if (getSupportActionBar() != null)
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    updateAppBarScrollFlag();

    mMainFab = (FloatingActionButton) findViewById(R.id.fab_main);

    if (UIUtils.isTablet(this)) {
        mMainFab.setSize(FloatingActionButton.SIZE_NORMAL);
    }

    updateFabGravity();

    mToolbar.setOnClickListener(new OnSingleClickListener() {
        @Override
        public void onSingleClick(View v) {
            //get top displaying fragment
            Fragment fg = getSupportFragmentManager().findFragmentById(R.id.main_frame_container);
            if (fg instanceof BaseFragment) {
                ((BaseFragment) fg).scrollToTop();
            }
        }
    });

    FragmentManager fragmentManager = getSupportFragmentManager();
    if (fragmentManager.findFragmentById(R.id.main_frame_container) == null) {
        Bundle arguments = getIntent().getExtras();
        ThreadDetailFragment fragment = new ThreadDetailFragment();
        fragment.setArguments(arguments);
        fragmentManager.beginTransaction()
                .add(R.id.main_frame_container, fragment).commit();
    }
}