Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #169 from teslacoil/master
Browse files Browse the repository at this point in the history
Fix vibrating windows
  • Loading branch information
afollestad committed Jan 6, 2015
2 parents 2d36924 + 781681a commit 4e9927d
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
Expand Down Expand Up @@ -421,9 +422,23 @@ private void setDividerVisibility(boolean topVisible, boolean bottomVisible) {
} else {
Resources r = getContext().getResources();
buttonBarDivider.setVisibility(View.GONE);

final int bottomMargin = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);
setVerticalMargins(view.findViewById(R.id.buttonStackedFrame), bottomMargin, bottomMargin);
setVerticalMargins(view.findViewById(R.id.buttonDefaultFrame), bottomMargin, bottomMargin);

/* Only enable the bottom margin if our available window space can hold the margin,
we don't want to enable this and cause the content to scroll, which is bad
experience itself but it also causes a vibrating window as this will keep getting
enabled/disabled over and over again.
*/
Rect maxWindowFrame = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(maxWindowFrame);
int currentHeight = getWindow().getDecorView().getMeasuredHeight();
if (currentHeight + bottomMargin < maxWindowFrame.height()) {
setVerticalMargins(view.findViewById(R.id.buttonStackedFrame),
bottomMargin, bottomMargin);
setVerticalMargins(view.findViewById(R.id.buttonDefaultFrame),
bottomMargin, bottomMargin);
}
}
}

Expand Down

0 comments on commit 4e9927d

Please sign in to comment.