We have a setting in our app "Left hand mode" that flips FABs to align the left side of the screen instead of the right (used by a small but appreciative audience :)).
I can't seem to find a way to programmatically flip the FAB speed dial menu items so they align to the left side of the screen instead of the right.
Here's what I have so far - I was able to flip the FAB itself - heres, the screenshot:
...
boolean leftHandMode = true; // This should flip all FABs to the left side of screen
if (mLayersFab != null) {
// Update all the Layers FAB-contained layouts
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mLayersFab.getFabContainer()
.getLayoutParams();
updateLeftHandMode(mLayersFab.getFabContainer(), layoutParams, leftHandMode);
layoutParams = (RelativeLayout.LayoutParams) mLayersFab
.getLayoutParams();
updateLeftHandMode(mLayersFab, layoutParams, leftHandMode);
layoutParams = (RelativeLayout.LayoutParams) mLayersFab.getButton().getLayoutParams();
updateLeftHandMode(mLayersFab.getButton(), layoutParams, leftHandMode);
for (int i = 0; i < mLayersFab.getButton().getChildCount(); i++) {
View v = mLayersFab.getChildAt(i);
RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) v.getLayoutParams();
updateLeftHandMode(v, p, leftHandMode);
}
}
...
private void updateLeftHandMode(View v, RelativeLayout.LayoutParams layoutParams,
boolean leftHandMode) {
if (leftHandMode) {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_END);
}
} else {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_LEFT);
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_START);
}
}
v.setLayoutParams(layoutParams);
}
Despite looping through the children views, I can't seem to get the expanded speed dial to align left - here's what it looks like expanded:
Ideally the placement of the bike icon and "bikeshare" text would be reversed when changed to the left margin (so the bike icon is against left side of screen), but I'd take just moving the existing label and icon to the left margin as-is.